Problem: There have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names.

Political parties find their number in the ballot highly important. Overall there are m possible numbers: 1, 2, ..., m. Each of these 7 parties is going to be assigned in some way to exactly one number, at that, two distinct parties cannot receive the same number.

The Little Elephant Political Party members believe in the lucky digits 4 and 7. They want to evaluate their chances in the elections. For that, they need to find out, how many correct assignments are there, such that the number of lucky digits in the Little Elephant Political Party ballot number is strictly larger than the total number of lucky digits in the ballot numbers of 6 other parties. 

Help the Little Elephant Political Party, calculate this number. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109 + 7).

Input

A single line contains a single positive integer m (7 ≤ m ≤ 109) — the number of possible numbers in the ballot.

Output

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

7


Output

0


Input

8


Output

1440

Solution (in CPP):

Solution:
#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;
}