#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long sz(long long x) {
  long long res = 0;
  while (x) {
    ++res;
    x /= 10;
  }
  return res;
}
long long d[20];
long long cnt[20];
long long dp1[20][3][20];
long long m;
long long ans = 0;
long long a[10];
long long sum = 0;
void go(long long pos) {
  if (pos == 6) {
    for (long long j = sum + 1; j < 20; ++j)
      if (cnt[j]) {
        ans = (ans + a[5] * cnt[j]) % MOD;
      }
    return;
  }
  if (pos == 0) {
    for (long long i = 0; i < 20; ++i)
      if (cnt[i]) {
        a[0] = cnt[i];
        --cnt[i];
        sum += i;
        go(pos + 1);
        ++cnt[i];
        sum -= i;
      }
  } else {
    for (long long i = 0; i < 20; ++i)
      if (cnt[i]) {
        a[pos] = (a[pos - 1] * cnt[i]) % MOD;
        --cnt[i];
        sum += i;
        go(pos + 1);
        ++cnt[i];
        sum -= i;
      }
  }
}
int main() {
  cin >> m;
  long long n = sz(m);
  for (long long i = 1; i <= n; ++i) {
    d[i] = m % 10;
    m /= 10;
  }
  reverse(d + 1, d + 1 + n);
  dp1[0][1][0] = 1;
  for (long long i = 1; i <= n; ++i)
    for (long long pr1 = 0; pr1 < 3; ++pr1)
      for (long long pr2 = 0; pr2 < 20; ++pr2)
        for (long long cur = 0; cur <= 9; ++cur)
          if (dp1[i - 1][pr1][pr2] && !(cur == 0 && i == 1)) {
            long long cc = pr2;
            if (cur == 4 || cur == 7) ++cc;
            if (pr1 == 0) dp1[i][0][cc] += dp1[i - 1][pr1][pr2];
            if (pr1 == 1) {
              if (cur < d[i]) dp1[i][0][cc] += dp1[i - 1][pr1][pr2];
              if (cur == d[i]) dp1[i][1][cc] += dp1[i - 1][pr1][pr2];
              if (cur > d[i]) dp1[i][2][cc] += dp1[i - 1][pr1][pr2];
            }
            if (pr1 == 2) dp1[i][2][cc] += dp1[i - 1][pr1][pr2];
          }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 0; j < 3; ++j)
      for (long long k = 0; k < 20; ++k)
        if (!(i == n && j == 2)) {
          cnt[k] += dp1[i][j][k];
        }
  }
  go(0);
  ans %= MOD;
  cout << ans << endl;
}
