#include <bits/stdc++.h>
using namespace std;
long long n;
int ok[1000005];
int b[1000005];
long long RR;
int memo[1000001][20][2];
int last = 1;
long long mod = 1e9 + 7;
long long F3[20];
long long F2[20];
int solve(int i, int j, int k) {
  if (i == n) {
    return j == 0 && k == 0;
  }
  int &ret = memo[i][j][k];
  if (ret != -1) return ret;
  ret = 0;
  long long temp = 0;
  if (k > 0) {
    long long p = F2[j] * F3[k];
    long long p2 = F2[j] * F3[k - 1];
    long long have = n / p2;
    have -= n / p;
    if (have > 0) temp += 1LL * have * solve(i + 1, j, k - 1);
    temp %= mod;
  }
  if (j > 0) {
    long long p = F2[j] * F3[k];
    long long p2 = F2[j - 1] * F3[k];
    long long have = n / p2;
    have -= n / p;
    if (have > 0) temp += 1LL * have * solve(i + 1, j - 1, k);
    temp %= mod;
  }
  long long p = F2[j] * F3[k];
  long long rem = n / p - i;
  if (rem > 0) temp += 1LL * rem * solve(i + 1, j, k);
  temp %= mod;
  ret = temp;
  return ret;
}
int main() {
  F2[0] = 1;
  F3[0] = 1;
  for (int i = 1; i < 20; i++) {
    F2[i] = F2[i - 1] * 2;
    F3[i] = F3[i - 1] * 3;
  }
  memset(memo, -1, sizeof(memo));
  cin >> n;
  int maxx = 0;
  for (int i = 2; i <= n; i++) {
    long long x = i;
    int cnt = 0;
    while (x % 2 == 0) {
      cnt++;
      x = x / 2;
    }
    while (x % 3 == 0) {
      cnt++;
      x = x / 3;
    }
    maxx = max(maxx, cnt);
    b[i] = cnt;
  }
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    if (b[i] == maxx) {
      last++;
      int R2 = 0;
      int R3 = 0;
      int temp = i;
      while (temp % 2 == 0) {
        temp = temp / 2;
        R2++;
      }
      while (temp % 3 == 0) {
        temp = temp / 3;
        R3++;
      }
      ans += solve(1, R2, R3);
      ans %= mod;
    }
  }
  cout << ans << endl;
}
