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;
vector<int> digits;
const int MOD = 1e9 + 7;
long long binpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD, b /= 2;
  }
  return ret;
}
void init(int m) {
  while (m > 0) {
    digits.push_back(m % 10);
    m /= 10;
  }
}
int dp[11][11][2];
int store[11];
int rec(int idx, int lucky, int less) {
  int &ret = dp[idx][lucky][less];
  if (ret != -1) return ret;
  if (idx == digits.size()) return ret = (lucky == 0);
  ret = 0;
  for (int i = 0; i <= 9; i++) {
    int sub = false, newless = false;
    if (i == 4 || i == 7)
      if (not lucky)
        continue;
      else
        sub = true;
    if (not less and digits[idx] < i) continue;
    if (digits[idx] > i) newless = true;
    ret += rec(idx + 1, lucky - sub, less | newless);
    ret %= MOD;
  }
  return ret;
}
int dp2[13][13][7];
long long invmod(long long a) { return binpow(a, MOD - 2); }
long long ways(long long n, long long r) {
  if (n < r) return 0LL;
  if (r == 0) return 1LL;
  long long ret = n;
  for (int cur = 2; cur <= r; cur++) {
    long long here = ((long long)(n - cur + 1) * invmod(cur)) % MOD;
    ret = (ret * here) % MOD;
  }
  return ret;
}
int rec2(int idx, int sum, int max, int left) {
  int &ret = dp2[idx][sum][left];
  if (ret != -1) return ret;
  if (idx == max) return ret = (left == 0);
  int cur = store[idx];
  ret = 0;
  for (int here = 0; here <= left; here++) {
    if (sum - here * idx < 0) continue;
    ret += ((long long)ways(cur, here) *
            rec2(idx + 1, sum - here * idx, max, left - here)) %
           MOD;
    ret %= MOD;
  }
  return ret;
}
int main() {
  int m;
  cin >> m;
  init(m);
  reverse(digits.begin(), digits.end());
  long long ans = 0;
  memset(dp, -1, sizeof dp);
  memset(dp2, -1, sizeof dp2);
  for (int i = 0; i <= 10; i++) {
    store[i] = rec(0, i, 0) - (i == 0);
  }
  for (int l = 1; l <= 10; l++) {
    long long here = ((long long)store[l] * rec2(0, l - 1, l, 6)) % MOD;
    ans = (ans + here) % MOD;
  }
  cout << (ans * 720) % MOD << endl;
}