#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
int m;
string s;
inline string intToStr(int x) {
  string ans = "";
  while (x > 0) {
    ans.push_back(x % 10);
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
inline bool read() {
  if (scanf("%d", &m) != 1) return false;
  return true;
}
int cnt[20];
int d[20][20][2];
inline void calc(int n, const string& s) {
  memset(d, 0, sizeof(d));
  d[0][0][1] = 1;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(11); j++)
      for (int k = 0; k < int(2); k++) {
        int dv = d[i][j][k];
        if (dv == 0) continue;
        for (int c = 0; c < int(10); c++) {
          if (k == 1 && c > s[i]) continue;
          int nk = (k == 1 && c == s[i]);
          int nj = j;
          if (c == 4 || c == 7) nj++;
          d[i + 1][nj][nk] += dv;
        }
      }
  for (int i = 0; i < int(11); i++)
    for (int j = 0; j < int(2); j++) cnt[i] += d[n][i][j];
  cnt[0]--;
  int tst = 0;
  for (int i = 0; i < int(11); i++) tst += cnt[i];
  assert(tst == m);
}
long long ans = 0;
pair<long long, int> tmp[20];
void calc(int pos) {
  if (pos == 7) {
    int sum = 0;
    for (int i = 0; i < int(6); i++) sum += tmp[i].second;
    if (sum >= tmp[6].second) return;
    long long dAns = 1;
    for (int i = 0; i < int(7); i++) dAns = (dAns * tmp[i].first) % mod;
    ans = (ans + dAns) % mod;
    return;
  }
  for (int i = 0; i < int(11); i++)
    if (cnt[i] > 0) {
      tmp[pos] = make_pair(cnt[i], i);
      cnt[i]--;
      calc(pos + 1);
      cnt[i]++;
    }
}
inline void solve() {
  s = intToStr(m);
  int n = int(s.size());
  calc(n, s);
  calc(0);
  cout << ans << endl;
}
int main() {
  assert(read());
  solve();
  return 0;
}
