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;
void outdouble(double x, int n) {
  cout.setf(ios::fixed);
  cout << setprecision(n) << (x) << endl;
}
void inout() {}
void work();
int main() {
  inout();
  work();
  return 0;
}
const long long lnf = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.141592653589793;
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5;
long long dp[20][20];
vector<int> r;
long long dfs(int len, int cnt, int o) {
  if (cnt < 0) return 0;
  if (!o && dp[len][cnt] != -1) return dp[len][cnt];
  if (len == 0) return cnt == 0;
  if (cnt > len) return 0;
  int n = o ? r[len - 1] : 9;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    int to = cnt - (i == 4 || i == 7);
    ans += dfs(len - 1, to, o && i == n);
    ans %= mod;
  }
  if (!o) dp[len][cnt] = ans;
  return ans;
}
long long cnt[20];
long long A(long long n, int k) {
  long long ans = 1;
  for (long long i = n; i > n - k; i--) {
    ans = ans * i % mod;
  }
  return ans;
}
long long sol(int a[], int l, int r) {
  long long ans = 0;
  for (int i = l; i <= r; i++) ans = (cnt[i] + ans) % mod;
  int c[10] = {0};
  for (int i = 0; i < 6; i++) c[a[i]]++;
  long long s = 1;
  for (int i = 0; i < l; i++) s = s * A(cnt[i], c[i]) % mod;
  return s * ans % mod;
}
void work() {
  int m;
  while (cin >> m) {
    r.clear();
    while (m) {
      r.push_back(m % 10);
      m /= 10;
    }
    memset(dp, -1, sizeof(dp));
    for (int i = r.size(); i >= 0; i--) {
      cnt[i] = dfs(r.size(), i, 1);
    }
    cnt[r.size() + 1] = 0;
    int len = 0;
    long long ans = 0;
    for (; cnt[len]; len++)
      ;
    cnt[0] = (cnt[0] - 1 + mod) % mod;
    for (int i1 = 0; cnt[i1]; i1++)
      for (int i2 = 0; cnt[i2]; i2++)
        for (int i3 = 0; cnt[i3]; i3++)
          for (int i4 = 0; cnt[i4]; i4++)
            for (int i5 = 0; cnt[i5]; i5++)
              for (int i6 = 0; cnt[i6]; i6++) {
                int sum = 0;
                int a[] = {i1, i2, i3, i4, i5, i6};
                for (int i = 0; i < 6; i++) sum += a[i];
                if (sum + 1 > len) continue;
                ans = (ans + sol(a, sum + 1, len)) % mod;
              }
    cout << ans << endl;
  }
}