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;
const int inf = 1 << 28;
const int mod = (int)1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
int n, m, mx;
long long cnt[20], fac[20];
long long c[10][10];
long long dp[15][15];
void init() {
  dp[0][0] = 1;
  for (int i = 0; i <= 10; i++)
    for (int j = 0; j <= i; j++)
      if (dp[i][j]) {
        dp[i + 1][j] += 8 * dp[i][j];
        dp[i + 1][j + 1] += 2 * dp[i][j];
      }
  fac[0] = 1;
  for (int i = 1; i <= 9; i++) fac[i] = i * fac[i - 1];
  c[0][0] = 1;
  for (int i = 1; i <= 9; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j <= i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
}
int a[15], len;
void calc(long long n) {
  long long tmp = n;
  while (tmp) {
    a[++len] = tmp % 10;
    tmp /= 10;
  }
  int nn = 0;
  for (int i = len; i >= 1; i--) {
    for (int j = 0; j < i; j++) {
      if (a[i] > 7) {
        cnt[j + nn] += (a[i] - 2) * dp[i - 1][j];
        cnt[j + 1 + nn] += 2 * dp[i - 1][j];
      } else if (a[i] > 4) {
        cnt[j + nn] += (a[i] - 1) * dp[i - 1][j];
        cnt[j + 1 + nn] += dp[i - 1][j];
      } else {
        cnt[j + nn] += a[i] * dp[i - 1][j];
      }
    }
    if (a[i] == 4 || a[i] == 7) nn++;
  }
  int tt = 0;
  for (int i = 1; i <= len; i++)
    if (a[i] == 4 || a[i] == 7) tt++;
  cnt[tt]++;
  cnt[0]--;
  for (mx = 10; mx >= 0; mx--) {
    if (cnt[mx] != 0) break;
  }
}
long long p(long long n, long long m) {
  long long ans = 1;
  for (int i = 0; i < m; i++) ans = ans * (n - i) % mod;
  return ans;
}
long long num[15], tmp, ans;
void dfs(int step, int mx, int sum, int k) {
  if (step == 6) {
    tmp = 1;
    int nn = 6;
    for (int i = mx - 1; i >= 0; i--) {
      tmp = tmp * c[nn][num[i]] * p(cnt[i], num[i]) % mod;
      nn -= num[i];
    }
    ans = (ans + cnt[mx] * tmp) % mod;
    return;
  }
  for (int i = k; i >= 0; i--) {
    if (cnt[i] > num[i] && sum + i < mx) {
      num[i]++;
      dfs(step + 1, mx, sum + i, i);
      num[i]--;
    }
  }
}
int main() {
  init();
  while (cin >> m) {
    calc(m);
    ans = 0;
    for (int i = 1; i <= mx; i++) {
      dfs(0ll, i, 0ll, i);
    }
    cout << ans << endl;
  }
  return 0;
}