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 = 1e9 + 7;
long long kpow(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return r;
}
void inc(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
int L, a[20], c[20], dp[20][20][2];
int fac[20], f[20][20][20];
int dfs(int t, int x, bool up) {
  if (t < 0) return x == 0;
  if (x < 0) return 0;
  if (~dp[t][x][up]) return dp[t][x][up];
  int ret = 0, u = up ? a[t] : 9;
  for (int i = (0); i < (u + 1); ++i)
    ret += dfs(t - 1, x - (i == 4 || i == 7), up & (i == u));
  return dp[t][x][up] = ret;
}
void calc(int n) {
  L = 0, memset(dp, -1, sizeof(dp));
  while (n > 0) a[L++] = n % 10, n /= 10;
  for (int i = (0); i < (L + 1); ++i) c[i] = dfs(L - 1, i, true) - (i == 0);
  fac[0] = 1;
  for (int i = (1); i < (10); ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
}
long long C(int n, int m) {
  int ret = kpow(fac[m], MOD - 2);
  for (int i = (0); i < (m); ++i) ret = 1ll * ret * (n - i) % MOD;
  return ret;
}
int solve() {
  for (int i = (0); i < (7); ++i) f[i][0][0] = C(c[0], i);
  for (int i = (0); i < (7); ++i) {
    for (int j = (0); j < (L + 1); ++j) {
      for (int k = (0); k < (j + 1); ++k) {
        if (!f[i][j][k]) continue;
        for (int ii = (i + 1); ii < (7); ++ii)
          for (int kk = (k + 1); kk < (L + 1); ++kk) {
            if (j + (ii - i) * kk > L) break;
            inc(f[ii][j + (ii - i) * kk][kk],
                1ll * f[i][j][k] * C(c[kk], ii - i) % MOD);
          }
      }
    }
  }
  int ans = 0;
  for (int i = (1); i < (L + 1); ++i) {
    int tmp = 0;
    for (int j = (0); j < (i); ++j)
      for (int k = (0); k < (j + 1); ++k) inc(tmp, f[6][j][k]);
    tmp = 1ll * tmp * c[i] % MOD * fac[6] % MOD;
    inc(ans, tmp);
  }
  return ans;
}
int main() {
  int m;
  scanf("%d", &m);
  calc(m);
  printf("%d", solve());
  return 0;
}