#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N = 1e5;
const int hashMod = 1e6 + 5;
const int inf = 0x55555555;
const double eps = 1e-8;
const long long linf = 0x5555555555555555ll;
const double finf = 1e50;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
int preCnt[N + 1][10], cnt[10];
int work(int n) {
  int ret = 0;
  while (n) {
    if (n % 10 == 4 || n % 10 == 7) ret++;
    n /= 10;
  }
  return ret;
}
void pre() {
  memset(preCnt[0], 0, sizeof(preCnt[0]));
  preCnt[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 10; j++) {
      preCnt[i][j] = preCnt[i - 1][j];
    }
    preCnt[i][work(i)]++;
  }
}
void cal(int n) {
  int hi = n / N, lo = n % N;
  int dg = hi ? log10(hi) + 1 : 0;
  int mk = work(hi);
  for (int i = 0; i < 10; i++) {
    cnt[i] = 0;
    if (hi >= 1) {
      for (int j = 0; j < min(i + 1, 6); j++) {
        if (i - j < 0) continue;
        cnt[i] += preCnt[hi - 1][i - j] * preCnt[N - 1][j];
      }
    }
    if (i - mk >= 0) cnt[i] += preCnt[lo][i - mk];
  }
  cnt[0]--;
}
long long ans;
int con[10];
void dfs(int depth, int remain) {
  if (depth >= 6) {
    long long tmp = 1ll;
    for (int i = 0; i < 10; i++) {
      int t = con[i];
      if (!t) continue;
      if (!cnt[i] || cnt[i] < t) return;
      while (t--) {
        tmp *= cnt[i] - t;
        tmp %= mod;
      }
    }
    ans += tmp;
    ans %= mod;
    return;
  }
  for (int i = 0; i < remain + 1; i++) {
    con[i]++;
    dfs(depth + 1, remain - i);
    con[i]--;
  }
}
void BF(int n) {
  for (int i = 0; i < 10; i++) cnt[i] = 0;
  for (int i = 1; i <= n; i++) {
    cnt[work(i)]++;
  }
}
int main() {
  int n;
  pre();
  while (cin >> n) {
    cal(n);
    long long tmp = 0ll;
    for (int i = 0; i < 9; i++) {
      ans = 0;
      dfs(0, i);
      ans *= cnt[i + 1];
      ans %= mod;
      tmp += ans;
      tmp %= mod;
    }
    cout << tmp << endl;
  }
  return 0;
}
