#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long kpow(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return r;
}
void inc(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
int L, a[20], c[20], dp[20][20][2];
int fac[20], f[20][20][20];
int dfs(int t, int x, bool up) {
  if (t < 0) return x == 0;
  if (x < 0) return 0;
  if (~dp[t][x][up]) return dp[t][x][up];
  int ret = 0, u = up ? a[t] : 9;
  for (int i = (0); i < (u + 1); ++i)
    ret += dfs(t - 1, x - (i == 4 || i == 7), up & (i == u));
  return dp[t][x][up] = ret;
}
void calc(int n) {
  L = 0, memset(dp, -1, sizeof(dp));
  while (n > 0) a[L++] = n % 10, n /= 10;
  for (int i = (0); i < (L + 1); ++i) c[i] = dfs(L - 1, i, true) - (i == 0);
  fac[0] = 1;
  for (int i = (1); i < (10); ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
}
long long C(int n, int m) {
  int ret = kpow(fac[m], MOD - 2);
  for (int i = (0); i < (m); ++i) ret = 1ll * ret * (n - i) % MOD;
  return ret;
}
int solve() {
  for (int i = (0); i < (7); ++i) f[i][0][0] = C(c[0], i);
  for (int i = (0); i < (7); ++i) {
    for (int j = (0); j < (L + 1); ++j) {
      for (int k = (0); k < (j + 1); ++k) {
        if (!f[i][j][k]) continue;
        for (int ii = (i + 1); ii < (7); ++ii)
          for (int kk = (k + 1); kk < (L + 1); ++kk) {
            if (j + (ii - i) * kk > L) break;
            inc(f[ii][j + (ii - i) * kk][kk],
                1ll * f[i][j][k] * C(c[kk], ii - i) % MOD);
          }
      }
    }
  }
  int ans = 0;
  for (int i = (1); i < (L + 1); ++i) {
    int tmp = 0;
    for (int j = (0); j < (i); ++j)
      for (int k = (0); k < (j + 1); ++k) inc(tmp, f[6][j][k]);
    tmp = 1ll * tmp * c[i] % MOD * fac[6] % MOD;
    inc(ans, tmp);
  }
  return ans;
}
int main() {
  int m;
  scanf("%d", &m);
  calc(m);
  printf("%d", solve());
  return 0;
}
