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;
long long ans[15], dp[15][15][15];
char str[15];
long long flag[15], tmp, n;
long long Num[15], mu2[15], mu8[15];
long long fuck;
long long C(long long k, long long m) {
  long long tmp = 1;
  for (long long i = 1; i <= k; i++) {
    tmp *= (m + 1 - i);
    tmp /= i;
  }
  return tmp;
}
long long work(long long k, long long m) {
  long long tmp = C(k, m);
  tmp *= mu2[k];
  tmp *= mu8[m - k];
  return tmp;
}
long long ni(long long x) {
  long long k = 1000000007 - 2;
  long long tmp = 1, a = x;
  while (k) {
    if (k % 2) tmp = tmp * a % 1000000007;
    k /= 2;
    a = a * a % 1000000007;
  }
  return tmp;
}
long long solve(long long i, long long x) {
  long long tmp = 1, b = 1;
  for (long long k = 0; k < i; k++) {
    tmp *= x - k;
    tmp %= 1000000007;
    b *= k + 1;
  }
  tmp *= ni(b);
  tmp %= 1000000007;
  return tmp;
}
int main() {
  while (~scanf("%s", str)) {
    fuck = 0;
    n = strlen(str);
    memset(flag, 0, sizeof(flag));
    memset(ans, 0, sizeof(ans));
    mu2[0] = mu8[0] = 1;
    for (int i = 1; i <= 10; i++) {
      mu2[i] = mu2[i - 1] * 2;
      mu8[i] = mu8[i - 1] * 8;
    }
    for (long long i = 0; i < n; i++) Num[i] = str[i] - '0';
    for (long long i = 0; i < n; i++) {
      tmp = Num[i];
      for (long long j = 0; j < tmp; j++) {
        if (j == 4 || j == 7) {
          for (long long k = 0; k < n - i; k++) {
            ans[1 + flag[i] + k] += work(k, n - i - 1);
          }
        } else {
          for (long long k = 0; k < n - i; k++) {
            ans[flag[i] + k] += work(k, n - i - 1);
          }
        }
      }
      if (tmp == 4 || tmp == 7) {
        flag[i + 1] = flag[i] + 1;
      } else
        flag[i + 1] = flag[i];
    }
    ans[flag[n]]++;
    ans[0]--;
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 0; i <= 9; i++) {
      for (int k = 0; k <= 6; k++) {
        for (int j = 0; j <= 10; j++) dp[i + 1][k][j] = dp[i][k][j];
      }
      for (int k = 0; k < 6; k++) {
        for (int j = 0; j <= 10; j++) {
          for (long long p = 1; p <= ans[i] && p <= 6 - k; p++) {
            if (p * i + j > 10) break;
            dp[i + 1][k + p][p * i + j] += dp[i][k][j] * solve(p, ans[i]);
            dp[i + 1][k + p][p * i + j] %= 1000000007;
          }
        }
      }
    }
    long long ans1[15];
    for (int i = 0; i < 9; i++) {
      ans1[i] = dp[10][6][i];
    }
    for (int i = 0; i < 9; i++) {
      fuck += ans1[i] * ans[i + 1];
      fuck %= 1000000007;
      ans1[i + 1] += ans1[i];
      ans1[i + 1] %= 1000000007;
    }
    fuck = fuck * 720 % 1000000007;
    printf("%I64d\n", fuck);
  }
  return 0;
}