#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int n, dp1[33][2], dp2[33][2], k;
int f(int x, int y) {
  int kk = 1 << x;
  if (y == 1) kk = kk * 3;
  return n / kk;
}
int main() {
  scanf("%d", &n);
  int k = (int)log2(n);
  dp1[k][0] = 1;
  if ((1 << (k - 1)) * 3 <= n) dp1[k - 1][1] = 1;
  for (int i = 1; i < n; i++) {
    memset(dp2, 0, sizeof(dp2));
    for (int x = 0; x <= k; x++) {
      for (int y = 0; y <= 1; y++) {
        dp2[x][y] = (dp2[x][y] + 1ll * dp1[x][y] * (f(x, y) - i)) % p;
        if (x)
          dp2[x - 1][y] =
              (dp2[x - 1][y] + 1ll * dp1[x][y] * (f(x - 1, y) - f(x, y))) % p;
        if (y)
          dp2[x][y - 1] =
              (dp2[x][y - 1] + 1ll * dp1[x][y] * (f(x, y - 1) - f(x, y))) % p;
      }
    }
    swap(dp1, dp2);
  }
  printf("%d\n", dp1[0][0]);
  return 0;
}
