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;
unsigned long long num[100] = {0};
unsigned long long numm[100] = {0};
long long M, M1;
int d[10];
unsigned long long ans = 0;
const unsigned long long z = 1000000007;
int yy[10] = {0};
int calc(int x) {
  int ans = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) ans++;
    x /= 10;
  }
  return ans;
}
void check() {
  memset(yy, 0, sizeof(yy));
  int all = 0;
  for (int i = 2; i <= 7; i++) all += d[i];
  if (all >= d[1]) return;
  unsigned long long now = 1;
  for (int i = 1; i <= 7; i++) {
    now *= (numm[d[i]] - yy[d[i]]);
    if (!now) return;
    now %= z;
    yy[d[i]]++;
  }
  ans += now;
  ans %= z;
}
void dfs(int i) {
  if (i > 7) {
    check();
    return;
  }
  for (int ii = 0; ii <= d[1]; ii++) {
    d[i] = ii;
    dfs(i + 1);
  }
}
void prework1() {
  M1 = M / 10000;
  for (int i = 0; i < M1; i++) num[calc(i)]++;
  for (int i = 0; i <= 9999; i++) {
    int n = calc(i);
    for (int ii = 0; ii <= 9; ii++)
      if (num[ii]) numm[n + ii] += num[ii];
  }
  for (int i = M1 * 10000; i <= M; i++) numm[calc(i)]++;
  numm[0]--;
}
int main() {
  cin >> M;
  prework1();
  for (d[1] = 1; d[1] <= 9; d[1]++) {
    if (!numm[d[1]]) break;
    dfs(2);
  }
  cout << ans << endl;
}