#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const string LN = "\n";
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = (int)2e9 + 7;
const long long LINF = (long long)9e18 + 7;
bool insert(int k, int x1, int x2) { return (k >= x1 && k <= x2); }
const int MAXN = 60007;
const int P1 = 239017;
const int P2 = 353251;
const long long MOD = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
int n;
vector<int> s;
long long ans = 0;
int d[8], kol[11], now[11];
int dp[15][2][15];
int rec(int p, bool f, int kol) {
  if (kol < 0) return 0;
  if (p == s.size() && kol == 0) return 1;
  if (p == s.size() && kol != 0) return 0;
  if (dp[p][f][kol] != -1) return dp[p][f][kol];
  if (f) {
    int ans = 0;
    for (int c = 0; c <= 9; c++) {
      if (c == 4 || c == 7) {
        ans += rec(p + 1, 1, kol - 1);
      } else {
        ans += rec(p + 1, 1, kol);
      }
    }
    dp[p][f][kol] = ans;
    return ans;
  } else {
    int ans = 0;
    for (int c = 0; c <= s[p]; c++) {
      if (c == 4 || c == 7) {
        ans += rec(p + 1, c != s[p], kol - 1);
      } else {
        ans += rec(p + 1, c != s[p], kol);
      }
    }
    dp[p][f][kol] = ans;
    return ans;
  }
}
void check() {
  for (int i = 0; i < 10; i++) now[i] = 0;
  long long res = 1;
  for (int i = 0; i < 7; i++) {
    int need = d[i];
    res = (res * (kol[need] - now[need])) % MOD;
    now[need]++;
  }
  ans = (ans + res) % MOD;
}
void go(int v, int sum) {
  if (v == 7) {
    check();
    return;
  }
  if (v == 0) {
    for (int i = 1; i <= 9; i++) {
      d[v] = i;
      go(v + 1, i - 1);
    }
  } else {
    for (int i = 0; i <= sum; i++) {
      d[v] = i;
      go(v + 1, sum - i);
    }
  }
}
const bool is_testing = 0;
int main() {
  if (is_testing) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cin >> n;
  int cop = n;
  while (cop) {
    s.push_back(cop % 10);
    cop /= 10;
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i < 13; i++)
    for (int j = 0; j < 13; j++)
      for (int f = 0; f < 2; f++) dp[i][f][j] = -1;
  for (int i = 0; i < 10; i++) kol[i] = rec(0, 0, i);
  kol[0]--;
  go(0, 0);
  cout << ans;
  if (is_testing) {
    cout << LN << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << LN;
  }
}
