#include <bits/stdc++.h>
using namespace std;
long long l, r, ans, mid, m, kol, cur, i, j, x, k, otv;
long long c[11], repeat[300001], a[100001][11], b[100001], res[11];
void sear() {
  l = 0;
  r = 9999;
  while (l <= r) {
    mid = (l + r) / 2;
    if (i * 10000 + mid <= m)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
}
void go(int len, int sum) {
  int j;
  if (len > 6) {
    kol = 1;
    for (k = 1; k <= 6; k++) kol = (c[k] * kol) % 1000000007;
    otv += kol;
    return;
  }
  for (j = 0; j <= 9; j++) {
    if (res[j] > repeat[j] && i > sum + j) {
      c[len] = res[j] - repeat[j];
      repeat[j]++;
      go(len + 1, sum + j);
      repeat[j]--;
    }
  }
}
int main() {
  cin >> m;
  a[0][0] = 1;
  for (i = 1; i < 100000; i++) {
    x = i;
    ans = 0;
    while (x) {
      if (x % 10 == 4 || x % 10 == 7) ans++;
      x /= 10;
    }
    for (j = 0; j < 6; j++) a[i][j] = a[i - 1][j];
    a[i][ans]++;
    b[i] = ans;
  }
  for (i = 0; i < 100000; i++) {
    ans = -1;
    sear();
    if (ans != -1)
      for (j = 0; j < 6; j++) {
        res[j + b[i]] += a[ans][j];
      }
  }
  if (m == 1000000000) res[0]++;
  res[0]--;
  for (i = 1; i <= 9; i++) {
    otv = 0;
    go(1, 0);
    cur = (cur + otv * res[i] % 1000000007) % 1000000007;
  }
  cout << cur % 1000000007;
}
