#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int INF = 1000000007;
const double eps = 1e-10;
const long long mod = 1000000007;
int dp[maxn][21][2];
int cal(int n, int x, int y) {
  int res = 0, tmp1, tmp2;
  tmp1 = 1 << x;
  tmp2 = (y == 0) ? 1 : 3;
  res = n / (tmp1 * tmp2);
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  int up2 = 0, up3 = 0;
  while ((1 << up2) <= n) up2++;
  if ((1 << up2) > n) up2--;
  if ((1 << (up2 - 1)) * 3 <= n) up3 = 1;
  for (int i = 0; i <= up3; i++) dp[1][up2 - i][i] = 1;
  for (int i = 2; i <= n; i++) {
    for (int x = 0; x <= up2; x++) {
      for (int y = 0; y <= up3; y++) {
        dp[i][x][y] = (dp[i][x][y] + 1ll * dp[i - 1][x][y] * 1ll *
                                         (cal(n, x, y) - (i - 1) + mod) % mod) %
                      mod;
        if (x > 0)
          dp[i][x - 1][y] =
              (dp[i][x - 1][y] + 1ll * dp[i - 1][x][y] * 1ll *
                                     (cal(n, x - 1, y) - cal(n, x, y) + mod) %
                                     mod) %
              mod;
        if (y > 0)
          dp[i][x][y - 1] =
              (dp[i][x][y - 1] + 1ll * dp[i - 1][x][y] * 1ll *
                                     (cal(n, x, y - 1) - cal(n, x, y) + mod) %
                                     mod) %
              mod;
      }
    }
  }
  printf("%d\n", dp[n][0][0]);
  return 0;
}
