#include <bits/stdc++.h>
using namespace std;
int power(int a, int b) {
  int res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int f(int n, int x, int y) {
  int a = (1LL << x);
  int b = 1;
  while (y--) b = b * 3;
  return (n / (a * b));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int x, y;
  int mod = 1e9 + 7;
  x = 0;
  long long int c = 1;
  while (c <= n) {
    c *= 2LL;
    x++;
  }
  x--;
  int dp[x + 1][2];
  int ndp[x + 1][2];
  for (int j = 0; j <= x; j++) {
    for (int k = 0; k < 2; k++) {
      dp[j][k] = 0;
      ndp[j][k] = 0;
    }
  }
  dp[x][0] = 1;
  if ((1LL << (x - 1)) * 3 <= n) dp[x - 1][1] = 1;
  for (int i = 0; i + 1 < n; i++) {
    for (int j = x; j >= 0; j--) {
      for (int k = 1; k >= 0; k--) {
        ndp[j][k] =
            (ndp[j][k] + ((long long int)dp[j][k] * (f(n, j, k) - i - 1))) %
            mod;
        if (j > 0)
          ndp[j - 1][k] = (ndp[j - 1][k] + ((long long int)dp[j][k] *
                                            (f(n, j - 1, k) - f(n, j, k)))) %
                          mod;
        if (k > 0)
          ndp[j][k - 1] = (ndp[j][k - 1] + ((long long int)dp[j][k] *
                                            (f(n, j, k - 1) - f(n, j, k)))) %
                          mod;
      }
    }
    for (int j = x; j >= 0; j--) {
      for (int k = 1; k >= 0; k--) {
        dp[j][k] = ndp[j][k];
        ndp[j][k] = 0;
      }
    }
  }
  cout << dp[0][0];
}
