#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10, mod = 1e9 + 7;
int dp[N][22][3];
long long x, y, n, ma, ans, cnt[25][25], qp[4][30];
int pos = 0;
long long slove() {
  memset(dp, 0, sizeof dp);
  dp[1][x][y] = 1;
  bool ok = 1;
  for (long long i = 2; i <= n; i++) {
    bool flag = 0;
    if (ok)
      for (long long k = 0; k < 2; k++) {
        for (long long j = 0; j < 20 && qp[2][j] * qp[3][k] <= n; j++) {
          if (dp[i - 1][j + 1][k] || dp[i - 1][j][k + 1]) flag = 1;
          long long res = 0;
          res = (res + (long long)dp[i - 1][j][k] * (cnt[j][k] - i + 1) % mod) %
                mod;
          res = (res + (long long)dp[i - 1][j + 1][k] *
                           (cnt[j][k] - cnt[j + 1][k]) % mod) %
                mod;
          res = (res + (long long)dp[i - 1][j][k + 1] *
                           (cnt[j][k] - cnt[j][k + 1]) % mod) %
                mod;
          dp[i][j][k] = res;
        }
      }
    else {
      long long res =
          ((long long)dp[i - 1][0][0] * (cnt[0][0] - i + 1) % mod) % mod;
      dp[i][0][0] = res;
    }
    if (!flag) ok = 0;
  }
  return dp[n][0][0];
}
int main() {
  qp[2][0] = qp[3][0] = 1;
  for (long long i = 1; i <= 25; i++)
    qp[2][i] = qp[2][i - 1] * 2, qp[3][i] = qp[3][i - 1] * 3;
  scanf("%lld", &n);
  for (long long i = 0; qp[2][i] <= n; i++)
    for (long long j = 0; j < 2 && qp[2][i] * qp[3][j] <= n; j++)
      ma = max(ma, i + j);
  for (long long k = 1; k <= n; k++)
    for (long long i = 0; qp[2][i] <= k; i++)
      for (long long j = 0; j < 2 && qp[2][i] * qp[3][j] <= k; j++)
        if (k % (qp[2][i] * qp[3][j]) == 0) cnt[i][j]++;
  for (long long i = 0; qp[2][i] <= n; i++)
    for (long long j = 0; j < 2 && qp[2][i] * qp[3][j] <= n; j++)
      if (ma == i + j) {
        x = i, y = j;
        ans = (ans + slove()) % mod;
      }
  printf("%lld\n", ans);
}
