#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200005;
const double eps = 1e-7;
const double DINF = 1e100;
const int INF = 1000000006;
const long long LINF = 1000000000000000005ll;
const int MOD = 1000000007;
int m, len;
long long g[20], a[20];
long long f[20][20], F[20][20];
long long fpow(long long a, long long t, long long mod) {
  long long rt = 1;
  for (; t; t >>= 1, a = a * a % mod)
    if (t & 1) rt = rt * a % mod;
  return rt;
}
long long dp(int i, int x) {
  if (x < 0 || x > i) return 0;
  if (f[i][x] != -1) return f[i][x];
  if (i == x) return fpow(2, x, MOD);
  f[i][x] = 8 * dp(i - 1, x) + 2 * dp(i - 1, x - 1);
  return f[i][x];
}
long long calc(int x) {
  long long ans = 0;
  for (int i = len; i >= 1; --i) {
    int t = -1;
    if (a[i] > 7) ans += dp(i - 1, x - 1);
    if (a[i] > 4) ans += dp(i - 1, x - 1);
    if (a[i] > 7)
      t = a[i] - 2;
    else if (a[i] > 4)
      t = a[i] - 1;
    else
      t = a[i];
    ans += t * dp(i - 1, x);
    if (a[i] == 4 || a[i] == 7) --x;
  }
  return ans;
}
long long A(long long x, long long k) {
  if (x < k) return 0;
  long long t = 1;
  for (long long i = x; i > x - k; --i) t = t * i % MOD;
  return t;
}
long long sum[20];
long long b[20];
long long count(int k, long long x) {
  if (k == 6) {
    memset(b, 0, sizeof(b));
    long long tmp = 1;
    for (int i = 0; i < 6; ++i) b[a[i]]++;
    for (int i = 0; i <= 10; ++i) tmp = tmp * A(g[i], b[i]) % MOD;
    return tmp;
  }
  long long rt = 0;
  for (int i = 0; i <= x; ++i) {
    a[k] = i;
    rt += count(k + 1, x - i);
    rt %= MOD;
  }
  return rt;
}
int main() {
  cin >> m;
  ++m;
  for (int t = m; t; t /= 10) a[++len] = t % 10;
  memset(f, -1, sizeof(f));
  dp(1, 1);
  for (int x = 0; x <= 10; ++x) g[x] = calc(x);
  --g[0];
  long long ans = 0;
  for (int x = 1; x <= 10; ++x) {
    ans += g[x] * count(0, x - 1) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
