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;
int m, limit, cnt, lst, kind, hv;
int w[15], num[15], dp[15][15];
long long al, h;
void dfs(int x, int last) {
  if (x == 7) {
    for (int i = 1; i <= lst; i++) h = h * (w[last] - i + 1) % 1000000007;
    for (int j = 1; j <= lst; j++) kind *= (7 - hv - j);
    for (int j = 1; j <= lst; j++) kind /= j;
    al = (al + kind * h) % 1000000007;
    return;
  }
  int start = min(last, limit - cnt);
  for (int i = start; i >= 0; i--) {
    if (i == last && lst == w[i]) continue;
    int res = lst, HV = hv, KI = kind;
    long long pre = h;
    if (i == last)
      lst++;
    else {
      if (last <= limit) {
        for (int j = 1; j <= lst; j++) h = h * (w[last] - j + 1) % 1000000007;
        for (int j = 1; j <= lst; j++) kind *= (7 - hv - j);
        for (int j = 1; j <= lst; j++) kind /= j;
        hv = x - 1;
      }
      lst = 1;
    }
    cnt += i;
    dfs(x + 1, i);
    lst = res;
    h = pre;
    cnt -= i;
    hv = HV;
    kind = KI;
  }
}
void init() {
  while (m) {
    num[++num[0]] = m % 10;
    m /= 10;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= 9; i++) {
    dp[i][0] = dp[i - 1][0] * 8 % 1000000007;
    for (int j = 1; j <= 9; j++)
      dp[i][j] = dp[i - 1][j] * 8 + dp[i - 1][j - 1] * 2;
  }
  int sum = 0;
  for (int i = num[0]; i >= 1; i--) {
    int cnt0 = num[i], cnt1 = 0;
    if (num[i] > 4) cnt1++, cnt0--;
    if (num[i] > 7) cnt1++, cnt0--;
    for (int j = 0; j < i; j++) {
      w[sum + j] += dp[i - 1][j] * cnt0;
      w[sum + j + 1] += dp[i - 1][j] * cnt1;
    }
    if (num[i] == 4 || num[i] == 7) sum++;
  }
  w[sum]++;
  w[0]--;
  return;
}
int main() {
  scanf("%d", &m);
  init();
  long long ans = 0;
  for (int i = 1; i <= 9; i++) {
    cnt = hv = 0;
    al = 0;
    h = kind = 1;
    limit = i - 1;
    lst = 0;
    dfs(1, i);
    ans = (ans + al * w[i]) % 1000000007;
  }
  ans = (ans + 1000000007) % 1000000007;
  printf("%lld\n", ans);
  return 0;
}