#include <bits/stdc++.h>
using namespace std;
FILE *in;
FILE *out;
const int MAX = 16;
const int MOD = 1000000007;
int maxNum;
char a[MAX];
int n;
int dyn[MAX][2][MAX];
int dp[MAX][MAX][MAX];
int cnt[MAX];
long long tri[MAX][MAX];
long long comb(int k, int n) {
  long long ret = 1;
  for (int i = 0; i < k; i++) {
    ret = (ret * (n - i)) % MOD;
  }
  return ret;
}
int recurse(int idx, int small, int rem) {
  if (idx >= n) {
    return (rem == 0);
  }
  if (dyn[idx][small][rem] != -1) {
    return dyn[idx][small][rem];
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    if (i > a[idx] - 48 && !small) break;
    int nsmall = (small || (i < a[idx] - 48));
    if (i == 4 || i == 7) {
      if (rem > 0) {
        ans += recurse(idx + 1, nsmall, rem - 1);
      }
    } else {
      ans += recurse(idx + 1, nsmall, rem);
    }
  }
  return dyn[idx][small][rem] = ans;
}
int go(int idx, int rem, int toUse) {
  if (rem == 0) {
    return 1;
  }
  if (idx < 0) {
    return 0;
  }
  if (dp[idx][rem][toUse] != -1) {
    return dp[idx][rem][toUse];
  }
  int ans = 0;
  for (int i = 0; i <= rem; i++)
    if (cnt[idx] >= i && toUse >= i * idx) {
      long long cur = go(idx - 1, rem - i, toUse - i * idx);
      cur = (cur * comb(i, cnt[idx])) % MOD;
      cur = (cur * tri[rem][i]) % MOD;
      ans = (ans + cur) % MOD;
    }
  return dp[idx][rem][toUse] = ans;
}
int main(void) {
  in = stdin;
  out = stdout;
  tri[0][0] = 1;
  for (int i = 1; i < MAX; i++) {
    tri[i][0] = tri[i][i] = 1;
    for (int c = 1; c < i; c++) {
      tri[i][c] = tri[i - 1][c - 1] + tri[i - 1][c];
    }
  }
  fscanf(in, "%d", &maxNum);
  sprintf(a, "%d", maxNum);
  n = (int)strlen(a);
  memset(dp, -1, sizeof(dp));
  memset(dyn, -1, sizeof(dyn));
  int ans = 0;
  cnt[0] = (recurse(0, 0, 0) - 1 + MOD) % MOD;
  for (int i = 1; i <= n; i++) {
    cnt[i] = recurse(0, 0, i);
    if (cnt[i] > 0) {
      ans += ((long long)cnt[i] * go(i - 1, 6, i - 1)) % MOD;
      if (ans >= MOD) ans -= MOD;
    }
  }
  fprintf(out, "%d\n", ans);
  return 0;
}
