#include <bits/stdc++.h>
using namespace std;
template <typename typ>
void vout(vector<typ>& v) {
  for (int vint = 0; vint < (int)(v).size(); vint++) cout << (v)[vint] << ' ';
  cout << endl;
}
template <typename typ>
void arrout(typ* arr, int l) {
  for (int i = 0; i < l; i++) cout << arr[i] << ' ';
  cout << endl;
}
long long int m;
long long mod = (long long)1e9 + 7;
long long int nL[10];
long long int cal_nL(long long int, int);
long long int pow_mod(int, long long int);
int C[10][10];
vector<vector<vector<int> > > partitions;
void set_partitions(int);
long long int sum_luck(int);
int main() {
  memset(C, 0, sizeof(C));
  C[0][0] = 1;
  for (int n = 1; n < 10; ++n) {
    C[n][0] = 1;
    for (int k = 1; k <= n; ++k) C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
  }
  cin >> m;
  for (int i = 0; i < 10; ++i) nL[i] = cal_nL(m, i);
  nL[0] -= 1;
  partitions.resize(9, vector<vector<int> >());
  partitions[0].resize(1, vector<int>(6, 0));
  for (int i = 1; i < 9; ++i) set_partitions(i);
  long long int ans = 0;
  long long int sum_of_luck[9];
  for (int i = 0; i < 9; ++i) {
    sum_of_luck[i] = sum_luck(i);
    if (i) sum_of_luck[i] = (sum_of_luck[i] + sum_of_luck[i - 1]) % mod;
  }
  for (int luck = 1; luck < 10; ++luck) {
    ans += (nL[luck] * sum_of_luck[luck - 1]) % mod;
    ans %= mod;
  }
  cout << (ans) << endl;
}
void set_partitions(int n) {
  vector<int> p(6, 0);
  for (p[0] = 0; p[0] <= n; ++p[0])
    for (p[1] = p[0]; p[1] + p[0] <= n; ++p[1])
      for (p[2] = p[1]; p[1] + p[2] + p[0] <= n; ++p[2])
        for (p[3] = p[2]; p[0] + p[1] + p[2] + p[3] <= n; p[3]++)
          for (p[4] = p[3]; p[4] + p[0] + p[1] + p[2] + p[3] <= n; ++p[4]) {
            p[5] = n - p[1] - p[2] - p[0] - p[3] - p[4];
            if (p[5] >= p[4]) partitions[n].push_back(p);
          }
}
long long int sum_luck(int luck) {
  long long int ans = 0;
  for (int i = 0; i < (int)(partitions[luck]).size(); ++i) {
    vector<int> count(9, 0);
    for (int j = 0; j < (int)(partitions[luck][i]).size(); ++j)
      count[partitions[luck][i][j]]++;
    long long int temp = 1;
    bool flag = false;
    int t = 6;
    for (int c = 0; c < 9; ++c) {
      temp *= C[t][count[c]];
      temp %= mod;
      t -= count[c];
      for (int k = 0; k < count[c]; ++k) {
        if (nL[c] - k > 0)
          temp = (temp * (nL[c] - k)) % mod;
        else {
          flag = true;
          break;
        }
      }
    }
    if (!flag) ans = (ans + temp) % mod;
  }
  return ans;
}
long long int cal_nL(long long int lim, int rem) {
  if (!lim) return !rem;
  long long int temp = lim;
  long long int p = 1;
  while (temp) {
    p *= 10;
    temp /= 10;
  }
  p /= 10;
  int dig = lim / p;
  long long int ans =
      (dig - (dig > 4 ? 1 : 0) - (dig > 7 ? 1 : 0)) * cal_nL(p - 1, rem);
  if (rem)
    ans += ((dig > 4 ? 1 : 0) + (dig > 7 ? 1 : 0)) * cal_nL(p - 1, rem - 1);
  if (dig != 4 && dig != 7)
    ans += cal_nL(lim % p, rem);
  else if (rem)
    ans += cal_nL(lim % p, rem - 1);
  return ans;
}
