#include <bits/stdc++.h>
using namespace std;
int m, l, tmax;
long long f[15][15][2], ans = 0, a[15], cnt[15], b[15], c[15], fac[7], inv[7];
void init() { scanf("%d", &m); }
long long calc(long long a, long long b) {
  if (b > a) return 0;
  int i;
  long long x = 1;
  for (i = 0; i < b; i++) x = x * (a - i) % 1000000007;
  x = x * inv[b] % 1000000007;
  return x;
}
void dfs(int step, int sum) {
  if (step == 7) {
    long long tot = 1;
    int i;
    for (i = 1; i <= tmax; i++)
      if (c[i]) tot = tot * calc(cnt[i] - cnt[i - 1], c[i]) % 1000000007;
    if (c[0]) tot = tot * calc(cnt[0], c[0]) % 1000000007;
    tot = (tot * (cnt[tmax] - cnt[sum])) % 1000000007;
    ans = (ans + tot) % 1000000007;
    return;
  }
  int i;
  for (i = b[step - 1]; i < tmax - sum; i++) {
    b[step] = i;
    c[i]++;
    dfs(step + 1, sum + i);
    c[i]--;
  }
}
long long ksm(long long x, long long y) {
  long long a = x, b = y, d = 1;
  while (b) {
    if (b & 1) d = d * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return d;
}
void work() {
  l = int(trunc(log10(m))) + 1;
  int t = m, k = l, i, j;
  while (t) {
    a[k--] = t % 10;
    t /= 10;
  }
  f[0][0][0] = 1;
  for (i = 0; i < l; i++)
    for (j = 0; j <= i; j++)
      for (k = 0; k <= 1; k++)
        if (f[i][j][k]) {
          if (k) {
            f[i + 1][j][k] =
                (f[i + 1][j][k] + f[i][j][k] * 8 % 1000000007) % 1000000007;
            f[i + 1][j + 1][k] =
                (f[i + 1][j + 1][k] + f[i][j][k] * 2 % 1000000007) % 1000000007;
          } else {
            if (a[i + 1] == 4 || a[i + 1] == 7)
              f[i + 1][j + 1][k] =
                  (f[i + 1][j + 1][k] + f[i][j][k]) % 1000000007;
            else
              f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % 1000000007;
            if (a[i + 1] >= 8) {
              f[i + 1][j + 1][1] =
                  (f[i + 1][j + 1][1] + f[i][j][k] * 2 % 1000000007) %
                  1000000007;
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * (a[i + 1] - 2) % 1000000007) %
                  1000000007;
            } else if (a[i + 1] >= 5) {
              f[i + 1][j + 1][1] =
                  (f[i + 1][j + 1][1] + f[i][j][k]) % 1000000007;
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * (a[i + 1] - 1) % 1000000007) %
                  1000000007;
            } else
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * a[i + 1] % 1000000007) %
                  1000000007;
          }
        }
  for (i = 0; i <= l; i++) cnt[i] = (f[l][i][0] + f[l][i][1]) % 1000000007;
  cnt[0] -= 1;
  tmax = l;
  while (!cnt[tmax] && tmax) tmax--;
  if (!tmax) {
    puts("0");
    return;
  }
  for (i = 1; i <= tmax; i++) cnt[i] = (cnt[i - 1] + cnt[i]) % 1000000007;
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = 1;
  for (i = 2; i <= 6; i++) {
    fac[i] = fac[i - 1] * i;
    inv[i] = ksm(fac[i], 1000000007 - 2);
  }
  dfs(1, 0);
  cout << (ans * 720) % 1000000007 << endl;
}
int main() {
  init();
  work();
  return 0;
}
