#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000100;
const int INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
long long m;
long long cnt[20];
long long f[20][20][20];
int num[maxn], len;
long long dfs(int i, int s, int x, bool e) {
  if (i == -1) return s == x;
  if (!e && ~f[i][s][x]) return f[i][s][x];
  long long res = 0;
  int u = e ? num[i] : 9;
  for (int d = 0; d <= u; d++) {
    int ns = s;
    if (d == 4 || d == 7) ns++;
    res = (res + dfs(i - 1, ns, x, e && d == u)) % MOD;
  }
  return e ? res : f[i][s][x] = res;
}
long long F(long long n, long long x) {
  len = 0;
  while (n) {
    num[len++] = n % 10;
    n /= 10;
  }
  return dfs(len - 1, 0, x, 1);
}
void getCnt() {
  memset(f, -1, sizeof(f));
  for (int i = 0; i <= 9; i++) cnt[i] = (F(m, i) + MOD - F(0, i)) % MOD;
}
long long dfs2(int cur, int limit, int sum) {
  if (cur == 6 + 1) return sum <= limit;
  long long res = 0;
  for (int i = 0; i <= 9; i++) {
    if (cnt[i] > 0) {
      cnt[i]--;
      res = (res + dfs2(cur + 1, limit, sum + i) * (cnt[i] + 1)) % MOD;
      cnt[i]++;
    }
  }
  return res;
}
void solve() {
  long long res = 0;
  for (int i = 1; i <= 9; i++) {
    res = (res + cnt[i] * dfs2(1, i - 1, 0)) % MOD;
  }
  cout << res << endl;
}
int main() {
  while (cin >> m) {
    getCnt();
    solve();
  }
  return 0;
}
