#include <bits/stdc++.h>
const int mod = (int)1e9 + 7;
long long power(long long a, int b) {
  long long ret = 1;
  while (b > 0) {
    if (b % 2) {
      ret *= a;
      ret %= mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ret;
}
long long inverse_mod(long long n) { return power(n, mod - 2); }
long long choose(long long n, int k) {
  if (k > n) {
    return 0;
  }
  int q = 1;
  for (int i = 1; i <= k; i++) {
    q *= i;
    q %= mod;
  }
  long long p = 1;
  for (long long i = n; i > n - k; i--) {
    p *= i;
    p %= mod;
  }
  return p * inverse_mod(q) % mod;
}
int main(void) {
  int m;
  scanf("%i", &m);
  char s[50];
  sprintf(s, "%i", m);
  int len = strlen(s);
  long long f[len + 1][len + 1][2];
  memset(f, 0, sizeof(f));
  f[0][0][1] = 1;
  for (int i = 0; i < len; i++) {
    for (int j = 0; j <= len; j++) {
      for (int eq = 0; eq <= 1; eq++) {
        long long cur = f[i][j][eq];
        for (char d = '0'; d <= '9'; d++) {
          if (eq && d > s[i]) {
            continue;
          }
          int n_eq = eq && (d == s[i]);
          int is_lucky = (d == '4' || d == '7') ? 1 : 0;
          f[i + 1][j + is_lucky][n_eq] += cur;
          f[i + 1][j + is_lucky][n_eq] %= mod;
        }
      }
    }
  }
  long long counts[len + 1];
  for (int i = 0; i <= len; i++) {
    counts[i] = f[len][i][0] + f[len][i][1];
    counts[i] %= mod;
  }
  counts[0] = (counts[0] + mod - 1) % mod;
  long long dp[len + 2][50 * len + 1][10];
  memset(dp, 0, sizeof(dp));
  dp[0][0][6] = 1;
  for (int i = 0; i <= len; i++) {
    for (int s = 0; s <= 7 * len; s++) {
      for (int r = 0; r <= 6; r++) {
        long long cur = dp[i][s][r];
        if (!cur) continue;
        for (int j = 0; j <= r; j++) {
          if (s + j * i <= 7 * len && r - j >= 0) {
            dp[i + 1][s + j * i][r - j] += cur * choose(counts[i], j) % mod;
            dp[i + 1][s + j * i][r - j] %= mod;
          }
        }
      }
    }
  }
  const int six_fact = 720;
  long long take[len + 1];
  for (int i = 0; i <= len; i++) {
    take[i] = dp[len + 1][i][0] * six_fact % mod;
  }
  long long ans = 0;
  for (int c = 1; c <= len; c++) {
    for (int i = 0; i < c; i++) {
      ans += take[i] * counts[c] % mod;
      ans %= mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
