#include <bits/stdc++.h>
using namespace std;
long long dp[2][25][2];
int main() {
  int n;
  cin >> n;
  int tmp = n, sum = 0;
  while (tmp > 1) tmp /= 2, sum++;
  dp[1][sum][0] = 1;
  if ((1 << (sum - 1)) * 3 <= n) dp[1][sum - 1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= sum; j++) {
      dp[i & 1][j][0] = dp[i & 1][j][1] = 0;
      dp[i & 1][j][0] += dp[!(i & 1)][j][0] * (n / (1 << j) - (i - 1));
      dp[i & 1][j][1] += dp[!(i & 1)][j][1] * (n / ((1 << j) * 3) - (i - 1));
      dp[i & 1][j][0] +=
          dp[!(i & 1)][j + 1][0] * (n / (1 << j) - n / (1 << (j + 1)));
      dp[i & 1][j][1] += dp[!(i & 1)][j + 1][1] *
                         (n / ((1 << j) * 3) - n / ((1 << (j + 1)) * 3));
      dp[i & 1][j][0] +=
          dp[!(i & 1)][j][1] * (n / (1 << j) - n / ((1 << j) * 3));
      dp[i & 1][j][0] %= 1000000007;
      dp[i & 1][j][1] %= 1000000007;
    }
  }
  cout << dp[n & 1][0][0];
  return 0;
}
