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 INF = 0x3f3f3f3f, P = 1e9 + 7, N = 30;
template <class T>
inline bool chkmin(T &A, T B) {
  return B < A ? A = B, 1 : 0;
}
template <class T>
inline bool chkmax(T &A, T B) {
  return A < B ? A = B, 1 : 0;
}
template <class T, class _>
inline void Add(T &first, _ second) {
  first += second;
  if (first >= P) first -= P;
  if (first < 0) first += P;
}
int ans, dp[N][N], cnt[N], A[N], tot;
int DP(int now, int cnt, int lim) {
  if (cnt < 0) return 0;
  if (now == -1) return cnt == 0;
  if (!lim && ~dp[now][cnt]) return dp[now][cnt];
  int res = 0;
  for (int i = (0), i_end = (lim ? A[now] : 9); i <= i_end; ++i)
    Add(res, DP(now - 1, cnt - (i == 4 || i == 7), lim && i == i_end));
  if (!lim) dp[now][cnt] = res;
  return res;
}
void calc(char *str) {
  memset(dp, -1, sizeof(dp));
  tot = strlen(str);
  for (int i = (0), i_end = (tot - 1); i <= i_end; ++i)
    A[i] = str[tot - i - 1] - '0';
  for (int i = (0), i_end = (tot); i <= i_end; ++i) cnt[i] = DP(tot - 1, i, 1);
}
long long Pow(long long first, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * first % P;
    first = first * first % P;
    k >>= 1;
  }
  return res;
}
long long C(int n, int m) {
  long long res = 1;
  for (int i = (n - m + 1), i_end = (n); i <= i_end; ++i) res = res * i % P;
  for (int i = (1), i_end = (m); i <= i_end; ++i) res = res * Pow(i, P - 2) % P;
  return res;
}
int Solve(int first) {
  int f[2][N][N], cur, w, res = 0;
  memset(f, cur = 0, sizeof(f));
  f[0][0][0] = 1;
  for (int tt = (0), tt_end = (first - 1); tt <= tt_end; ++tt) {
    memset(f[!cur], 0, sizeof(f[cur]));
    for (int i = (0), i_end = (6); i <= i_end; ++i)
      for (int j = (0), j_end = (first - 1); j <= j_end; ++j)
        if ((w = f[cur][i][j]))
          for (int k = (0), k_end = (min(cnt[tt], 6 - i)); k <= k_end; ++k) {
            if (tt * k + j >= first) continue;
            Add(f[!cur][i + k][j + tt * k], w * C(cnt[tt], k) % P);
          }
    cur = !cur;
  }
  for (int i = (0), i_end = (first - 1); i <= i_end; ++i)
    Add(res, f[cur][6][i]);
  return res;
}
int main() {
  char str[N];
  scanf("%s", str);
  calc(str);
  cnt[0]--;
  for (int i = (0), i_end = (19); i <= i_end; ++i)
    if (cnt[i]) {
      --cnt[i];
      Add(ans, (1ll * Solve(i) * (cnt[i] + 1)) % P);
      ++cnt[i];
    }
  for (int i = (1), i_end = (6); i <= i_end; ++i) ans = 1ll * ans * i % P;
  printf("%d\n", ans);
  return 0;
}