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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const string LN = "\n";
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = (int)2e9 + 7;
const long long LINF = (long long)9e18 + 7;
bool insert(int k, int x1, int x2) { return (k >= x1 && k <= x2); }
const int MAXN = 60007;
const int P1 = 239017;
const int P2 = 353251;
const long long MOD = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
int n;
vector<int> s;
long long ans = 0;
int d[8], kol[11], now[11];
int dp[15][2][15];
int rec(int p, bool f, int kol) {
  if (kol < 0) return 0;
  if (p == s.size() && kol == 0) return 1;
  if (p == s.size() && kol != 0) return 0;
  if (dp[p][f][kol] != -1) return dp[p][f][kol];
  if (f) {
    int ans = 0;
    for (int c = 0; c <= 9; c++) {
      if (c == 4 || c == 7) {
        ans += rec(p + 1, 1, kol - 1);
      } else {
        ans += rec(p + 1, 1, kol);
      }
    }
    dp[p][f][kol] = ans;
    return ans;
  } else {
    int ans = 0;
    for (int c = 0; c <= s[p]; c++) {
      if (c == 4 || c == 7) {
        ans += rec(p + 1, c != s[p], kol - 1);
      } else {
        ans += rec(p + 1, c != s[p], kol);
      }
    }
    dp[p][f][kol] = ans;
    return ans;
  }
}
void check() {
  for (int i = 0; i < 10; i++) now[i] = 0;
  long long res = 1;
  for (int i = 0; i < 7; i++) {
    int need = d[i];
    res = (res * (kol[need] - now[need])) % MOD;
    now[need]++;
  }
  ans = (ans + res) % MOD;
}
void go(int v, int sum) {
  if (v == 7) {
    check();
    return;
  }
  if (v == 0) {
    for (int i = 1; i <= 9; i++) {
      d[v] = i;
      go(v + 1, i - 1);
    }
  } else {
    for (int i = 0; i <= sum; i++) {
      d[v] = i;
      go(v + 1, sum - i);
    }
  }
}
const bool is_testing = 0;
int main() {
  if (is_testing) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cin >> n;
  int cop = n;
  while (cop) {
    s.push_back(cop % 10);
    cop /= 10;
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i < 13; i++)
    for (int j = 0; j < 13; j++)
      for (int f = 0; f < 2; f++) dp[i][f][j] = -1;
  for (int i = 0; i < 10; i++) kol[i] = rec(0, 0, i);
  kol[0]--;
  go(0, 0);
  cout << ans;
  if (is_testing) {
    cout << LN << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << LN;
  }
}