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