#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int MOD = 1e9 + 7;
long long comb[15][15], pw2[15], pw8[15], cnt[15];
void precalc() {
  for (int n = 0; n < 15; n++) {
    comb[n][0] = 1;
    for (int k = 1; k <= n; k++)
      comb[n][k] = comb[n - 1][k] + comb[n - 1][k - 1];
  }
  pw2[0] = 1;
  pw8[0] = 1;
  for (int i = 1; i < 15; i++) {
    pw2[i] = pw2[i - 1] * 2;
    pw8[i] = pw8[i - 1] * 8;
  }
}
long long solve(int party, int accu, int sum) {
  if (party == 6) {
    return max(0LL, cnt[sum - accu]);
  }
  long long res = 0LL;
  for (int i = 0; i <= sum - accu; i++) {
    if (cnt[i] > 0) {
      cnt[i]--;
      long long next_lvl = solve(party + 1, accu + i, sum);
      cnt[i]++;
      res = (res + (cnt[i] * next_lvl) % MOD) % MOD;
    }
  }
  return res;
}
int main() {
  precalc();
  int m;
  cin >> m;
  vector<int> dig;
  while (m > 0) {
    dig.push_back(m % 10);
    m /= 10;
  }
  int len = dig.size(), delta = 0;
  for (int i = len - 1; i >= 0; i--) {
    for (int j = 0; j < dig[i]; j++) {
      for (int k = 0; k <= i; k++) {
        int k2 = k + delta + ((j == 4 or j == 7) ? 1 : 0);
        cnt[k2] += comb[i][k] * pw2[k] * pw8[i - k];
      }
    }
    if (dig[i] == 4 or dig[i] == 7) delta++;
  }
  cnt[delta]++;
  cnt[0]--;
  for (int i = 0; i < 15; i++) cnt[i] %= MOD;
  long long ans = 0;
  for (int p0 = 1; p0 <= 9; p0++) {
    long long tans = cnt[p0];
    cnt[p0]--;
    for (int sum = 0; sum < p0; sum++) {
      ans = (ans + (tans * solve(1, 0, sum)) % MOD) % MOD;
    }
    cnt[p0]++;
  }
  cout << ans << endl;
  return 0;
}
