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;
template <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return s == 0 ? 0 : cntbit(s >> 1) + (s & 1);
}
const double PI = acos(-1.0);
const double eps = 1e-9;
const int dr[] = {-1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
const int inf = (int)1e9 + 5;
const long long linf = (long long)1e16 + 5;
const long long mod = (long long)1e9 + 7;
int n, K, a[11];
long long dp[11][2][11], dem[11], f[11][11][11];
long long go(int pos, int small, int lucky) {
  if (pos < 0) return lucky == K ? 1 : 0;
  if (lucky > K) return 0;
  long long &ret = dp[pos][small][lucky];
  if (ret != -1) return ret;
  ret = 0;
  int maxd = (small ? 9 : a[pos]);
  for (int d = (0); d <= (maxd); ++d) {
    ret += go(pos - 1, small || (d < a[pos]),
              lucky + ((d == 4 || d == 7) ? 1 : 0));
  }
  return ret;
}
long long modpow(long long a, int n) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long comb(int n, int k) {
  if (k > n) return 0;
  long long ret = 1;
  for (int i = (1); i <= (k); ++i) {
    ret = ret * (n - k + i) % mod;
    ret = ret * modpow(i, mod - 2) % mod;
  }
  return ret;
}
long long rec(int at, int i, int sum) {
  if (at < 0) return i == 0 ? 1 : 0;
  long long &ret = f[at][i][sum];
  if (ret != -1) return ret;
  ret = rec(at - 1, i, sum);
  for (int j = 1, lucky = at; j <= i && lucky <= sum; ++j, lucky += at) {
    ret += rec(at - 1, i - j, sum - lucky) * comb(dem[at], j) % mod;
    ret %= mod;
  }
  return ret;
}
long long doit() {
  memset(f, -1, sizeof(f));
  long long ret = 0;
  for (int K = (1); K <= (n); ++K) {
    ret += rec(n, 6, K - 1) * dem[K] % mod * 720 % mod;
    ret %= mod;
  }
  return ret;
}
long long solve(int m) {
  n = 0;
  while (m > 0) {
    a[n++] = m % 10;
    m /= 10;
  }
  memset(dem, 0, sizeof(dem));
  for (K = 0; K <= n; ++K) {
    memset(dp, -1, sizeof(dp));
    dem[K] = go(n - 1, 0, 0);
  }
  dem[0]--;
  return doit();
}
int main() {
  int m;
  cin >> m;
  cout << solve(m) << endl;
  return 0;
}