#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 1e5 + 15;
const int inf = 1e9;
const int maxe = 200000;
char a[30];
int n, b[30];
long long cnt[30];
long long dp[150][150] = {0};
long long fac[maxn + 5], inv[maxn + 5], dp2[30][30][30];
long long ans = 0;
long long powmod(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b = b / 2;
  }
  return ans;
}
void solve() {
  fac[0] = 1;
  for (int i = 1; i <= maxn; i++) fac[i] = fac[i - 1] * i % mod;
  inv[maxn] = powmod(fac[maxn], mod - 2, mod);
  for (int i = maxn - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
void init() {
  solve();
  dp[0][0] = 1;
  for (int i = 1; i <= 12; i++)
    for (int j = 0; j <= 12; j++) {
      dp[i][j] = (dp[i - 1][j] * 8 + dp[i - 1][j - 1] * 2) % mod;
    }
}
void dfs(int id, int num) {
  if (id > n) {
    cnt[num] = (cnt[num] + 1) % mod;
    return;
  }
  if (b[id] == 4 || b[id] == 7)
    dfs(id + 1, num + 1);
  else
    dfs(id + 1, num);
  for (int i = b[id] - 1; i >= 0; i--) {
    int z = num;
    if (i == 4 || i == 7) z++;
    int now = n - id;
    for (int j = z; j < 15; j++) cnt[j] = (cnt[j] + dp[now][j - z]) % mod;
  }
}
long long C(long long n, long long m) {
  n %= mod;
  long long ans = 1;
  for (int i = 0; i < m; i++) ans = ans * (n - i) % mod;
  return ans * inv[m] % mod;
}
void go() {
  dp2[0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= min(cnt[i], (long long)6); j++) {
      long long now = C(cnt[i], j);
      for (int x = 0; x + j <= 6; x++)
        for (int y = 0; y + j * i <= n; y++)
          if (dp2[i][x][y]) {
            dp2[i + 1][x + j][y + j * i] =
                (dp2[i][x][y] * now % mod + dp2[i + 1][x + j][y + j * i]) % mod;
          }
    }
  }
  for (int i = n - 1; i >= 0; i--) cnt[i] = (cnt[i] + cnt[i + 1]) % mod;
  for (int i = 0; i <= n; i++) {
    long long now = dp2[n + 1][6][i] * 720 % mod;
    ans += now * cnt[i + 1] % mod;
    ans %= mod;
  }
}
int main() {
  init();
  scanf("%s", a);
  n = strlen(a);
  for (int i = 0; i < n; i++) b[i + 1] = a[i] - '0';
  dfs(1, 0);
  n += 5;
  cnt[0]--;
  go();
  printf("%I64d\n", ans % mod);
}
