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 cnt[10] = {0};
vector<int> lmt;
long long dp[12][12][2];
int isLucky(int i) {
  if (i == 4 or i == 7)
    return 1;
  else
    return 0;
}
long long solve(int idx, int left, int tight) {
  if (idx == (int)lmt.size())
    return (left == 0);
  else if (dp[idx][left][tight] != -1)
    return dp[idx][left][tight];
  long long ret = 0;
  if (tight) {
    for (int i = 0; i < lmt[idx]; i++)
      ret += solve(idx + 1, left - isLucky(i), 0);
    ret += solve(idx + 1, left - isLucky(lmt[idx]), 1);
  } else {
    for (int i = 0; i < 10; i++) ret += solve(idx + 1, left - isLucky(i), 0);
  }
  return (dp[idx][left][tight] = ret);
}
long long F(int l) {
  for (int i = (int)(0); i < (int)(12); i++)
    for (int j = (int)(0); j < (int)(12); j++)
      for (int k = (int)(0); k < (int)(2); k++) dp[i][j][k] = -1;
  return solve(0, l, 1);
}
int main() {
  int n;
  cin >> n;
  while (n) {
    lmt.push_back(n % 10);
    n /= 10;
  }
  reverse(lmt.begin(), lmt.end());
  for (int i = 0; i < 10; i++) cnt[i] = F(i);
  long long ans = 0;
  cnt[0] -= 1;
  for (int i = 0; i < 9; i++) {
    long long A = cnt[i];
    cnt[i] -= 1;
    for (int j = 0; (i + j) < 9; j++) {
      long long B = cnt[j];
      cnt[j] -= 1;
      for (int k = 0; (i + j + k) < 9; k++) {
        long long C = cnt[k];
        cnt[k] -= 1;
        for (int l = 0; (i + j + k + l) < 9; l++) {
          long long D = cnt[l];
          cnt[l] -= 1;
          for (int m = 0; (i + j + k + l + m) < 9; m++) {
            long long E = cnt[m];
            cnt[m] -= 1;
            for (int n = 0; (i + j + k + l + m + n) < 9; n++) {
              if (i + j + k + l + m + n >= 9) break;
              long long F = cnt[n];
              cnt[n] -= 1;
              long long me = 0;
              int s = i + j + k + l + m + n + 1;
              for (; s < 10; s++) me += cnt[s];
              me = (me * F) % 1000000007;
              me = (me * D) % 1000000007;
              me = (me * B) % 1000000007;
              me = (me * E) % 1000000007;
              me = (me * C) % 1000000007;
              me = (me * A) % 1000000007;
              ans = (ans + me) % 1000000007;
              cnt[n] += 1;
            }
            cnt[m] += 1;
          }
          cnt[l] += 1;
        }
        cnt[k] += 1;
      }
      cnt[j] += 1;
    }
    cnt[i] += 1;
  }
  cout << ans << endl;
  return 0;
}