#include <bits/stdc++.h>
using namespace std;
int n, dp[1000005][21][2];
int f(int x, int y) {
  int a = (1 << x);
  if (y > 0) a *= 3;
  return n / a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, 0, sizeof dp);
  cin >> n;
  int p = 0;
  while ((1 << p) <= n) p++;
  p--;
  dp[1][p][0] = 1;
  if ((1 << (p - 1)) * 3 <= n) dp[1][p - 1][1] = 1;
  for (int i = 1; i < n; i++) {
    for (int x = p; x >= 0; x--) {
      for (int y = 0; y <= 1; y++) {
        dp[i + 1][x][y] =
            (dp[i + 1][x][y] + 1ll * dp[i][x][y] * (f(x, y) - i)) % 1000000007;
        if (x > 0)
          dp[i + 1][x - 1][y] = (dp[i + 1][x - 1][y] +
                                 1ll * dp[i][x][y] * (f(x - 1, y) - f(x, y))) %
                                1000000007;
        if (y > 0)
          dp[i + 1][x][y - 1] = (dp[i + 1][x][y - 1] +
                                 1ll * dp[i][x][y] * (f(x, y - 1) - f(x, y))) %
                                1000000007;
      }
    }
  }
  cout << dp[n][0][0] << "\n";
  return 0;
}
