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 N, L;
vector<int> digit;
long long dp[12][12][12][2];
int A[10] = {0, 1, 2, 3, 4, 4, 5, 6, 6, 7};
int B[10] = {1, 1, 1, 1, 0, 1, 1, 0, 1, 1};
long long recur(int lv, int c4, int c7, bool isTop) {
  if (dp[lv][c4][c7][isTop] != -1) return dp[lv][c4][c7][isTop];
  if (lv == L) {
    if (c4 + c7) return 0;
    return 1;
  } else {
    if (c4 + c7 > L - lv) return 0;
    int lim = 9;
    if (isTop) lim = digit[lv];
    int res = 0;
    if (lim > 6 && c7)
      res = (res + recur(lv + 1, c4, c7 - 1, isTop && digit[lv] == 7)) %
            1000000007;
    if (lim > 3 && c4)
      res = (res + recur(lv + 1, c4 - 1, c7, isTop && digit[lv] == 4)) %
            1000000007;
    if (!isTop)
      res = (res + 8 * recur(lv + 1, c4, c7, 0)) % 1000000007;
    else {
      res = (res + A[lim] * recur(lv + 1, c4, c7, 0)) % 1000000007;
      res = (res + B[lim] * recur(lv + 1, c4, c7, 1)) % 1000000007;
    }
    if (lv == 0 && c4 == 0 && c7 == 0 && isTop)
      res = (res + (1000000007 - 1)) % 1000000007;
    return dp[lv][c4][c7][isTop] = res;
  }
}
long long C[12][12];
long long ans;
void go(int lv, int rem, long long tmp) {
  if (!tmp) return;
  if (lv == 0) {
    ans = (ans + tmp) % 1000000007;
  } else {
    for (int i = (0); i < (L + 1); ++i)
      for (int j = (0); j < (L + 1) && (rem > i + j); ++j) {
        if (C[i][j]) {
          long long q = C[i][j];
          C[i][j]--;
          go(lv - 1, rem - i - j, (tmp * q) % 1000000007);
          C[i][j]++;
        }
      }
  }
}
long long C_bf[12][12];
int main(int argc, char **argv) {
  cin >> N;
  int tmp = N;
  memset(dp, -1, sizeof(dp));
  for (; tmp; tmp /= 10) digit.push_back(tmp % 10);
  reverse(digit.begin(), digit.end());
  L = digit.size();
  for (int j = (0); j < (L + 1); ++j)
    for (int k = (0); k < (L + 1) && (j + k <= L); ++k)
      fprintf(stderr, "With %d 4's, %d 7's, count = %lld\n", j, k,
              C[j][k] = recur(0, j, k, 1));
  for (int j = (0); j < (L + 1); ++j)
    for (int k = (0); k < (L + 1) && (j + k <= L); ++k) go(6, j + k, C[j][k]);
  cout << ans;
  return 0;
}