#include <bits/stdc++.h>
using namespace std;
int n, lim;
int dp[1000010][20][2];
inline long long calc(int x, int y) { return n / ((1 << x) * (y ? 3 : 1)); }
int main() {
  cin >> n;
  while ((1 << lim) <= n) lim++;
  lim--;
  dp[1][lim][0] = 1;
  if ((1 << lim - 1) * 3 <= n) dp[1][lim - 1][1] = 1;
  for (int i = 1; i < n; i++)
    for (int j = 0; j <= lim; j++)
      for (int k = 0; k < 2; k++) {
        if (!dp[i][j][k]) continue;
        (dp[i + 1][j][k] += dp[i][j][k] * (calc(j, k) - i) % 1000000007) %=
            1000000007;
        if (j)
          (dp[i + 1][j - 1][k] += dp[i][j][k] * (calc(j - 1, k) - calc(j, k)) %
                                  1000000007) %= 1000000007;
        if (k)
          (dp[i + 1][j][k - 1] += dp[i][j][k] * (calc(j, k - 1) - calc(j, k)) %
                                  1000000007) %= 1000000007;
      }
  cout << dp[n][0][0] << endl;
  return 0;
}
