#include <bits/stdc++.h>
using namespace std;
int n;
int lp[1000005];
vector<int> prime;
void sieve(int n) {
  for (int i = (2); i <= (n); i++) {
    if (!lp[i]) {
      prime.push_back(i);
      lp[i] = i;
    }
    for (auto u : prime) {
      if (u > lp[i] || 1LL * u * i > n) break;
      lp[1LL * u * i] = u;
    }
  }
}
vector<pair<int, int> > fac[1000005];
int cntfac[1000005];
int cntFac(int n) {
  int cnt = 0, ni = n;
  while (n > 1) {
    int p = lp[n];
    if (fac[ni].empty() || fac[ni].back().first != p)
      fac[ni].push_back({p, 1});
    else
      fac[ni][(int)fac[ni].size() - 1].second++;
    n /= p;
    ++cnt;
  }
  return cntfac[ni] = cnt;
}
struct md {
  int v;
  md(int _v = 0) { v = _v; }
  void operator+=(md n) { v = (0LL + v + n.v) % 1000000007; }
  void operator*=(md n) { v = (1LL * v * n.v) % 1000000007; }
};
md operator+(md a, md b) {
  a += b;
  return a;
}
md operator*(md a, md b) {
  a *= b;
  return a;
}
md fact[1000005];
md ans = 0;
md bigmod(md b, int i) {
  md r = 1;
  for (int k = (29); k >= (0); k--) {
    r *= r;
    if ((i >> k) & 1) r *= b;
  }
  return r;
}
md ncr(int n, int r) {
  return fact[n] * bigmod(fact[r], 1000000007 - 2) *
         bigmod(fact[n - r], 1000000007 - 2);
}
vector<int> tmp;
int num[25];
int freq[25];
void recur(int u, int t, int i) {
  if (i > cntfac[u]) {
    for (int j = (0); j <= (i - 1); j++) {
      freq[j] = n / num[j];
    }
    for (int j = (i - 1); j >= (1); j--) freq[j] -= freq[j - 1];
    md pdt = 1;
    int sum = 0;
    for (int j = (i - 1); j >= (0); j--) {
      pdt *= fact[freq[j]] * ncr(sum + freq[j] - 1, freq[j] - 1);
      sum += freq[j];
    }
    ans += pdt;
    return;
  }
  for (int j = (0); j <= ((int)fac[u].size() - 1); j++) {
    if (fac[u][j].second) {
      num[i] = t / fac[u][j].first;
      fac[u][j].second--;
      recur(u, num[i], i + 1);
      fac[u][j].second++;
    }
  }
}
int main() {
  scanf("%d", &n);
  sieve(n);
  int two = 0, t = n;
  while (t > 1) {
    t >>= 1;
    ++two;
  }
  int a = (1 << two);
  tmp.push_back(a);
  int b = a / 2 * 3;
  if (b <= n) tmp.push_back(b);
  fact[0] = 1;
  for (int i = (1); i <= (n); i++) {
    fact[i] = fact[i - 1] * i;
  }
  for (auto u : tmp) {
    cntFac(u);
    num[0] = u;
    recur(u, u, 1);
  }
  printf("%d\n", ans.v);
  return 0;
}
