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 mod = 1000000007;
const int maxn = 1e5 + 15;
const int inf = 1e9;
const int maxe = 200000;
char a[30];
int n, b[30];
long long cnt[30];
long long dp[150][150] = {0};
long long fac[maxn + 5], inv[maxn + 5], dp2[30][30][30];
long long ans = 0;
long long powmod(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b = b / 2;
  }
  return ans;
}
void solve() {
  fac[0] = 1;
  for (int i = 1; i <= maxn; i++) fac[i] = fac[i - 1] * i % mod;
  inv[maxn] = powmod(fac[maxn], mod - 2, mod);
  for (int i = maxn - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
void init() {
  solve();
  dp[0][0] = 1;
  for (int i = 1; i <= 12; i++)
    for (int j = 0; j <= 12; j++) {
      dp[i][j] = (dp[i - 1][j] * 8 + dp[i - 1][j - 1] * 2) % mod;
    }
}
void dfs(int id, int num) {
  if (id > n) {
    cnt[num] = (cnt[num] + 1) % mod;
    return;
  }
  if (b[id] == 4 || b[id] == 7)
    dfs(id + 1, num + 1);
  else
    dfs(id + 1, num);
  for (int i = b[id] - 1; i >= 0; i--) {
    int z = num;
    if (i == 4 || i == 7) z++;
    int now = n - id;
    for (int j = z; j < 15; j++) cnt[j] = (cnt[j] + dp[now][j - z]) % mod;
  }
}
long long C(long long n, long long m) {
  n %= mod;
  long long ans = 1;
  for (int i = 0; i < m; i++) ans = ans * (n - i) % mod;
  return ans * inv[m] % mod;
}
void go() {
  dp2[0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= min(cnt[i], (long long)6); j++) {
      long long now = C(cnt[i], j);
      for (int x = 0; x + j <= 6; x++)
        for (int y = 0; y + j * i <= n; y++)
          if (dp2[i][x][y]) {
            dp2[i + 1][x + j][y + j * i] =
                (dp2[i][x][y] * now % mod + dp2[i + 1][x + j][y + j * i]) % mod;
          }
    }
  }
  for (int i = n - 1; i >= 0; i--) cnt[i] = (cnt[i] + cnt[i + 1]) % mod;
  for (int i = 0; i <= n; i++) {
    long long now = dp2[n + 1][6][i] * 720 % mod;
    ans += now * cnt[i + 1] % mod;
    ans %= mod;
  }
}
int main() {
  init();
  scanf("%s", a);
  n = strlen(a);
  for (int i = 0; i < n; i++) b[i + 1] = a[i] - '0';
  dfs(1, 0);
  n += 5;
  cnt[0]--;
  go();
  printf("%I64d\n", ans % mod);
}