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 n, dp[2][11][11], E[11], lucky, sisa, ans;
vector<long long> V;
long long DP[11][11][11];
long long numD[10];
long long find(int istop, int x, int num) {
  if (num == 0) {
    if (istop) {
      long long tmp = 0;
      for (int j = x; j >= 0; j--) tmp = tmp * 10 + V[j];
      tmp++;
      return tmp;
    } else
      return E[x + 1];
  }
  if (x < 0) return 0;
  long long &ret = dp[istop][x][num];
  if (ret != -1) return ret;
  ret = 0;
  int mx = 9;
  if (istop) mx = V[x];
  for (int i = 0; i <= mx; i++) {
    if (i == 4 || i == 7) {
      ret += find((i == mx) && istop, x - 1, num - 1);
    } else
      ret += find((i == mx) && istop, x - 1, num);
  }
  return ret;
}
long long cari(int x, int sum, int k) {
  if (sum == 0) return 0;
  if (x > 6) return 1;
  if (k > 8) return 0;
  if (numD[k] == 0) return 0;
  long long &ret = DP[x][sum][k];
  if (ret != -1) return ret;
  ret = cari(x, sum, k + 1);
  long long tmp = 1;
  long long tmp2 = 0;
  long long j = 0;
  for (int i = x; i <= 6; i++) {
    tmp2 += k;
    if (tmp2 >= sum) break;
    tmp = (tmp * (numD[k] - j) % 1000000007ll) % 1000000007ll;
    if (numD[k] - j <= 0) break;
    ret = (ret + (tmp * cari(i + 1, sum - tmp2, k + 1)) % 1000000007ll) %
          1000000007ll;
    cout << x << " " << sum << " " << k << " | " << i << " | " << tmp << " | "
         << numD[k] - j << " | " << ret << endl;
    j++;
  }
  return ret;
}
long long ar[7];
long long cari(int sum) {
  long long ret = 0;
  long long tmp = 0;
  for (int a1 = 0; a1 <= 8; a1++) {
    if (numD[a1] == 0) continue;
    ar[0] = numD[a1];
    numD[a1]--;
    for (int a2 = 0; a2 <= 8; a2++) {
      if (numD[a2] == 0) continue;
      ar[1] = numD[a2];
      numD[a2]--;
      for (int a3 = 0; a3 <= 8; a3++) {
        if (numD[a3] == 0) continue;
        ar[2] = numD[a3];
        numD[a3]--;
        for (int a4 = 0; a4 <= 8; a4++) {
          if (numD[a4] == 0) continue;
          ar[3] = numD[a4];
          numD[a4]--;
          for (int a5 = 0; a5 <= 8; a5++) {
            if (numD[a5] == 0) continue;
            ar[4] = numD[a5];
            numD[a5]--;
            for (int a6 = 0; a6 <= 8; a6++) {
              if (numD[a6] == 0) continue;
              ar[5] = numD[a6];
              numD[a6]--;
              tmp = 1;
              if (a1 + a2 + a3 + a4 + a5 + a6 >= sum) {
                numD[a6]++;
                continue;
              }
              for (int i = 0; i < 6; i++) tmp = (tmp * ar[i]) % 1000000007ll;
              ret = (ret + tmp) % 1000000007ll;
              numD[a6]++;
            }
            numD[a5]++;
          }
          numD[a4]++;
        }
        numD[a3]++;
      }
      numD[a2]++;
    }
    numD[a1]++;
  }
  return ret;
}
long long c[11];
void coba() {
  memset(c, 0, sizeof(c));
  for (long long i = 1; i <= n; i++) {
    long long v = i;
    int tmp = 0;
    while (v > 0) {
      if ((v % 10) == 4 || (v % 10) == 7) tmp++;
      v /= 10;
    }
    c[tmp]++;
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%I64d", &n);
  long long v = n;
  E[0] = 1;
  for (int i = 0; i < 10; i++) {
    if (i == 0)
      E[i] = 1;
    else
      E[i] = E[i - 1] * 10ll;
    V.push_back(v % 10);
    v /= 10;
  }
  ans = 0;
  long long sum = 0;
  memset(numD, 0, sizeof(numD));
  numD[0] = n;
  for (int j = 1; j <= 9; j++) {
    lucky = find(1, 9, j);
    numD[j] = lucky;
    numD[j - 1] -= lucky;
  }
  memset(c, 0, sizeof(c));
  memset(DP, -1, sizeof(DP));
  ans = 0;
  for (int i = 1; i <= 9; i++) {
    if (numD[i] == 0) break;
    ans = (ans + (numD[i] * cari(i)) % 1000000007ll) % 1000000007ll;
  }
  printf("%I64d\n", ans);
  return 0;
}