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 long double EPS = 1E-9;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double PI = 2 * acos(.0);
long long dp[10][10][2];
vector<int> number;
int pivot = 1;
long long solve(int pos, bool is_bounded, int lucky_digits) {
  long long &memo = dp[pos][lucky_digits][is_bounded];
  if (lucky_digits > pivot) return 0;
  if (pos == (int)(number).size()) return 1;
  if (memo != -1) return memo;
  memo = 0;
  int upto = 9;
  if (is_bounded) upto = number[pos];
  for (int i = 0; i <= upto; i++) {
    bool next_bound = is_bounded && (upto == i);
    int next_lucky = lucky_digits + ((i == 4 || i == 7) ? 1 : 0);
    int next_pos = pos + 1;
    memo += solve(next_pos, next_bound, next_lucky);
  }
  return memo;
}
const long long MOD = 1000000007ll;
long long bigPow(long long a, long long b) {
  long long resp = 1;
  while (b) {
    if (b & 1) resp = (resp * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return resp % MOD;
}
long long inv(long long x) { return bigPow(x, MOD - 2); }
long long binCoefRec(int nn, int kk) {
  if (nn == kk) return 1ll;
  if (kk == 0) return 1ll;
  long long bin = (binCoefRec(nn - 1, kk - 1) * nn) % MOD;
  long long resp = (bin * inv(kk)) % MOD;
  return resp;
}
set<string> occur_set[10];
bool cent[10];
void find_occur(string seed, int times, int last) {
  if (times > 9) return;
  occur_set[times].insert(seed);
  for (int i = last; i < (int)(10); i++) {
    seed[i]++;
    seed[0]--;
    find_occur(seed, times + i, i);
    seed[i]--;
    seed[0]++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int m;
  cin >> m;
  while (m) {
    number.push_back(m % 10);
    m /= 10;
  }
  reverse(number.begin(), number.end());
  long long lucky_id[10];
  long long calc = 0, calc_bef = 0;
  long long ans = 0;
  find_occur("6000000000", 0, 1);
  for (pivot = 0; pivot < 10; pivot++) {
    for (int i = 0; i < (int)(10); i++)
      for (int j = 0; j < (int)(10); j++)
        for (int k = 0; k < (int)(2); k++) dp[i][j][k] = -1;
    calc = solve(0, true, 0) - 1;
    lucky_id[pivot] = calc - calc_bef;
    calc_bef = calc;
    if (pivot == 0 || lucky_id[pivot] == 0) continue;
    for (int x = 0; x < pivot; x++) {
      set<string>::iterator p = occur_set[x].begin();
      while (p != occur_set[x].end()) {
        long long temp = 1;
        bool cant = 1;
        for (int i = 0; i < (int)((*p).size()); i++) {
          if (i > pivot) continue;
          if ((*p)[i] < '0' || lucky_id[i] < ((*p)[i] - '0')) {
            cant = 0;
            break;
          }
          temp =
              (((temp) % MOD) * binCoefRec(lucky_id[i], (*p)[i] - '0')) % MOD;
        }
        if (cant == 0)
          temp = 0;
        else
          temp = (temp * lucky_id[pivot]) % MOD;
        ans = (ans + temp * 720) % MOD;
        p++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}