#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define MOD 10000007
#define N 101
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
typedef long long LL;
using namespace std;
LL c[N][N][N],n;int t[N];
void init_C(int n)
{
  int i,j,k;
  FOR(i,0,n) FOR(j,0,n) FOR(k,0,n) c[i][j][k]=1;
  FOR(k,1,n)
  {
    c[k][0][0]=k;
    FOR(i,1,n)
    {
      c[k][i][0]=k;
      FOR(j,1,i) 
      {
        c[k][i][j]=c[k][i-1][j]*c[k][i-1][j-1]%MOD;
      }
    }
  }
}
LL getans(int x,int t)
{
  LL res=t+1;int i;
  FOR(i,1,x-1)
  {
    LL tmp=c[i+t][x-1][i];
    res*=tmp;res%=MOD;
  }
  return res;
}
int main()
{
  init_C(80);
  scanf("%lld",&n);
  int len=0,i;LL tn=n;
  while (tn)
  {
    t[++len]=tn&1;
    tn/=2;
  }
  int c1=0;
  LL ans=1;
  ROF(i,len,1)
  {
    if (t[i]==1)
    {
      ans*=getans((LL)i,c1);
      ans%=MOD;
    }
    c1+=t[i];
  }
  printf("%lld\n",ans);
}