#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline double dist(double ix, double iy, double jx, double jy) {
  return sqrt(((ix - jx) * (ix - jx)) + ((iy - jy) * (iy - jy)));
}
int marked[1000000 / 64 + 2];
bool isPrime(int x) {
  return (x > 1) &&
         ((x == 2) ||
          ((x & 1) && (!((marked[x >> 6] & (1 << ((x & 63) >> 1)))))));
}
void seive(int n) {
  int i, j;
  for (i = 3; i * i <= n; i += 2) {
    if (!(marked[i >> 6] & (1 << ((i & 63) >> 1)))) {
      for (j = i * i; j <= n; j += i << 1) {
        marked[j >> 6] |= (1 << ((j & 63) >> 1));
      }
    }
  }
}
long long bigMod(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) (r *= a) %= 1000000007;
    b >>= 1;
    (a *= a) %= 1000000007;
  }
  return r;
}
long long fc[20], inv[20], how[20];
int vis[20];
long long inverse(long long a) { return bigMod(a, 1000000007 - 2); }
long long nCr(long long n, long long r) {
  return (fc[n] * ((inv[r] * inv[n - r]) % 1000000007)) % 1000000007;
}
int main() {
  int i, j, k, x, m, n, dig, pre, mask;
  long long pw, ans, cnt1, cnt2, now, cnt, cn;
  fc[0] = inv[0] = 1;
  for (i = 1; i <= 10; i++) {
    fc[i] = (fc[i - 1] * i) % 1000000007;
    inv[i] = inverse(fc[i]);
  }
  scanf("%d", &m);
  for (i = 0; i < 10; i++) how[i] = 0;
  n = m;
  dig = 0;
  pw = 1;
  while (n) {
    dig++;
    n /= 10;
    pw *= 10;
  }
  pre = 0;
  for (i = dig - 1; i >= 0; i--) {
    pw /= 10;
    x = m / pw;
    ;
    for (j = 0; j <= i; j++) {
      now = nCr(i, j) * bigMod(2, j) * bigMod(8, i - j);
      for (k = 0; k < (i ? x : x + 1); k++)
        how[j + pre + (k == 4 || k == 7)] += now;
      ;
    }
    if (x == 4 || x == 7) pre++;
    m %= pw;
  }
  how[0]--;
  for (j = 0; j < 10; j++)
    ;
  ans = 0;
  for (mask = 0; mask < 10000000; mask++) {
    m = mask;
    for (i = 0; i < 10; i++) vis[i] = 0;
    for (k = i = 0; i < 6; i++) {
      k += m % 10;
      vis[m % 10]++;
      m /= 10;
    }
    if (k < m) {
      cnt1 = 1;
      for (i = 0; i < 10; i++) {
        cn = 1;
        for (j = 0; j < vis[i]; j++)
          (cn *= max((how[i] - j), 0LL)) %= 1000000007;
        (cnt1 *= cn) %= 1000000007;
      }
      ans += (cnt1 * how[m]) % 1000000007;
      ans %= 1000000007;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
