#include <bits/stdc++.h>
using namespace std;
void outdouble(double x, int n) {
  cout.setf(ios::fixed);
  cout << setprecision(n) << (x) << endl;
}
void inout() {}
void work();
int main() {
  inout();
  work();
  return 0;
}
const long long lnf = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.141592653589793;
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5;
long long dp[20][20];
vector<int> r;
long long dfs(int len, int cnt, int o) {
  if (cnt < 0) return 0;
  if (!o && dp[len][cnt] != -1) return dp[len][cnt];
  if (len == 0) return cnt == 0;
  if (cnt > len) return 0;
  int n = o ? r[len - 1] : 9;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    int to = cnt - (i == 4 || i == 7);
    ans += dfs(len - 1, to, o && i == n);
    ans %= mod;
  }
  if (!o) dp[len][cnt] = ans;
  return ans;
}
long long cnt[20];
long long A(long long n, int k) {
  long long ans = 1;
  for (long long i = n; i > n - k; i--) {
    ans = ans * i % mod;
  }
  return ans;
}
long long sol(int a[], int l, int r) {
  long long ans = 0;
  for (int i = l; i <= r; i++) ans = (cnt[i] + ans) % mod;
  int c[10] = {0};
  for (int i = 0; i < 6; i++) c[a[i]]++;
  long long s = 1;
  for (int i = 0; i < l; i++) s = s * A(cnt[i], c[i]) % mod;
  return s * ans % mod;
}
void work() {
  int m;
  while (cin >> m) {
    r.clear();
    while (m) {
      r.push_back(m % 10);
      m /= 10;
    }
    memset(dp, -1, sizeof(dp));
    for (int i = r.size(); i >= 0; i--) {
      cnt[i] = dfs(r.size(), i, 1);
    }
    cnt[r.size() + 1] = 0;
    int len = 0;
    long long ans = 0;
    for (; cnt[len]; len++)
      ;
    cnt[0] = (cnt[0] - 1 + mod) % mod;
    for (int i1 = 0; cnt[i1]; i1++)
      for (int i2 = 0; cnt[i2]; i2++)
        for (int i3 = 0; cnt[i3]; i3++)
          for (int i4 = 0; cnt[i4]; i4++)
            for (int i5 = 0; cnt[i5]; i5++)
              for (int i6 = 0; cnt[i6]; i6++) {
                int sum = 0;
                int a[] = {i1, i2, i3, i4, i5, i6};
                for (int i = 0; i < 6; i++) sum += a[i];
                if (sum + 1 > len) continue;
                ans = (ans + sol(a, sum + 1, len)) % mod;
              }
    cout << ans << endl;
  }
}
