#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC optimize("fast-math")
using namespace std;
const int DEBUG = 0;
mt19937 gen(
    (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
#pragma comment(linker, "/STACK:16777216")
const int N = (int)1e6 + 20;
const int MOD = (int)1e9 + 7;
int dp[N][20][2];
int n;
int f(int p2, int p3) {
  int x = n / (1 << p2);
  if (p3) x /= 3;
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(cout.fixed);
  cout.precision(12);
  cin >> n;
  int pow2 = 0;
  while ((1 << pow2) <= n) pow2++;
  --pow2;
  dp[1][pow2][0] = 1;
  if ((1 << (pow2 - 1)) * 3 <= n) dp[1][pow2 - 1][1] = 1;
  for (int i = 1; i < n; i++)
    for (int p2 = 0; p2 <= pow2; p2++)
      for (int p3 = 0; p3 <= 1; p3++) {
        dp[i + 1][p2][p3] =
            (dp[i + 1][p2][p3] + 1LL * dp[i][p2][p3] * (f(p2, p3) - i)) % MOD;
        if (p2 > 0)
          dp[i + 1][p2 - 1][p3] =
              (dp[i + 1][p2 - 1][p3] +
               1LL * dp[i][p2][p3] * (f(p2 - 1, p3) - f(p2, p3))) %
              MOD;
        if (p3 > 0)
          dp[i + 1][p2][p3 - 1] =
              (dp[i + 1][p2][p3 - 1] +
               1LL * dp[i][p2][p3] * (f(p2, p3 - 1) - f(p2, p3))) %
              MOD;
      }
  cout << dp[n][0][0];
  return 0;
}
