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 N = 100000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
string f(long long x) {
  string res;
  while (x) {
    res += (char)('0' + x % 10);
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}
vector<int> get(int x) {
  string s = f(x);
  int n = (int)s.size();
  int dp[n + 1][2][10];
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < 2; j++)
      for (int c = 0; c < 10; c++) dp[i][j][c] = 0;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int c = 0; c < 10; c++) {
      if (dp[i][0][c] != 0) {
        dp[i + 1][0][c + (s[i] == '4' || s[i] == '7')] += dp[i][0][c];
        for (int x = 0; x < s[i] - '0'; x++)
          dp[i + 1][1][c + (x == 4 || x == 7)] += dp[i][0][c];
      }
      if (dp[i][1][c] != 0) {
        for (int x = 0; x < 10; x++)
          dp[i + 1][1][c + (x == 4 || x == 7)] += dp[i][1][c];
      }
    }
  }
  vector<int> ans(10, 0);
  for (int c = 0; c < 10; c++) ans[c] = dp[n][0][c] + dp[n][1][c];
  return ans;
}
long long bin_pow(long long a, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    p >>= 1;
  }
  return res;
}
long long C(long long n, long long k) {
  if (n < k) return 0;
  long long res = 1;
  for (int i = 0; i < k; i++) {
    res = res * (n - i) % MOD;
    res = res * bin_pow(i + 1, MOD - 2) % MOD;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  long long m;
  cin >> m;
  vector<int> a = get(m);
  a[0]--;
  long long dp[11][7][10];
  for (int i = 0; i < 11; i++)
    for (int j = 0; j < 7; j++)
      for (int k = 0; k < 10; k++) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 7; j++)
      for (int k = 0; k < 10; k++)
        for (int c = 0; c < 7 - j; c++)
          if (k + i * c < 10)
            dp[i + 1][j + c][k + i * c] =
                (dp[i + 1][j + c][k + i * c] + dp[i][j][k] * C(a[i], c)) % MOD;
  long long ans = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < i; j++) ans = (ans + a[i] * dp[10][6][j]) % MOD;
  cout << ans * 720 % MOD << "\n";
  return 0;
}