#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, D = 16, mod = 1000000007;
int n, d, t, g, x, a[D], r[D], h[D], bk[D][D], p[D];
long long ans;
int po(int a, int b) {
  int p = 1;
  for (int i = 1; i <= b; i++) p *= a;
  return p;
}
int bi(int a, int b) {
  int p[6];
  long long pr = 1;
  for (int i = 0; i < 6; i++) p[i] = 0;
  if (b >= 2) p[2] += 1;
  if (b >= 3) p[3] += 1;
  if (b >= 4) p[2] += 2;
  if (b >= 5) p[5] += 1;
  if (b == 6) p[2] += 1, p[3] += 1;
  for (int i = a; i > a - b; i--) {
    int k = i;
    for (int j = 0; j < 6; j++)
      while (p[j] && !(k % j)) k /= j, p[j]--;
    pr = (pr * (long long)k) % mod;
  }
  return pr;
}
int fa(int a) {
  int p = 1;
  for (int i = 1; i <= a; i++) p *= i;
  return p;
}
void rek(int c, int p) {
  if (c == x) {
    if (p) return;
    int sum = 0;
    for (int i = 0; i < x; i++) sum += h[i] * i;
    if (sum >= x) return;
    long long pr = 1;
    sum = 6;
    for (int i = 0; i < x; i++)
      pr = pr * bi(r[i], h[i]) % mod * bi(sum, h[i]) % mod * fa(h[i]) % mod,
      sum -= h[i];
    ans = (ans + pr * r[c]) % mod;
    return;
  }
  for (int i = 0; i <= min(r[c], p); i++) h[c] = i, rek(c + 1, p - i);
}
int main() {
  scanf("%d", &n);
  bk[0][0] = 1;
  for (int i = 1; i < D; i++) {
    bk[i][0] = 1;
    for (int j = 1; j < D; j++) bk[i][j] = bk[i - 1][j - 1] + bk[i - 1][j];
  }
  while (n) a[++d] = n % 10, n /= 10;
  reverse(a + 1, a + d + 1);
  for (int i = 1; i <= d; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (j == 4 || j == 7) g = 1;
      for (int p = 0; p <= d - i; p++)
        r[p + t + g] += bk[d - i][p] * po(2, p) * po(8, d - i - p);
      g = 0;
    }
    if (a[i] == 7 || a[i] == 4) t++;
  }
  r[t]++;
  r[0]--;
  for (int i = 1; i <= d; i++) x = i, rek(0, 6);
  printf("%d\n", ans);
  return 0;
}
