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, N = 11;
long long dp[N][N][N];
long long f[N];
int m;
long long cal(int m, int k) {
  vector<int> v;
  while (m > 0) {
    v.push_back(m % 10);
    m /= 10;
  }
  long long r = 0;
  if (k == 0) r = -1;
  for (int i = int(v.size()) - 1; i >= 0; --i) {
    int e = v[i] - 1;
    if (i == 0) e++;
    for (int j = 0; j <= e; ++j) {
      r += dp[i + 1][j][k];
    }
    if (v[i] == 4 || v[i] == 7) k--;
    if (k < 0) break;
  }
  return r;
}
vector<int> st;
long long C(long long n, long long m) {
  if (n == 0) return 0;
  long long r = 1;
  for (int i = 1; i <= m; ++i) {
    r = r * (n - i + 1) % Mod;
  }
  return r;
}
int fac[N];
long long sum;
void dfs(int lef) {
  if (int(st.size()) == 6) {
    if (lef != 0) return;
    int cnt = 1, tmp = 720;
    long long t = 1;
    for (int i = 1; i < 6; ++i) {
      if (st[i] == st[i - 1])
        cnt++;
      else {
        t = t * C(f[st[i - 1]], cnt) % Mod;
        tmp /= fac[cnt];
        cnt = 1;
      }
    }
    t = t * C(f[st[5]], cnt) % Mod;
    tmp /= fac[cnt];
    t = t * tmp % Mod;
    sum = (sum + t) % Mod;
    return;
  }
  int beg = 0;
  if (int(st.size()) != 0) beg = st.back();
  for (int i = beg; i <= lef; ++i) {
    st.push_back(i);
    dfs(lef - i);
    st.pop_back();
  }
}
int main() {
  for (int j = 0; j <= 9; ++j) {
    if (j == 4 || j == 7) {
      dp[1][j][0] = 0;
      dp[1][j][1] = 1;
    } else {
      dp[1][j][0] = 1;
      dp[1][j][1] = 0;
    }
  }
  for (int i = 2; i <= 10; ++i) {
    for (int j = 0; j <= 9; ++j) {
      for (int k = 0; k <= i; ++k) {
        for (int o = 0; o <= 9; ++o) {
          if (j == 4 || j == 7) {
            if (k == 0)
              dp[i][j][k] = 0;
            else
              dp[i][j][k] += dp[i - 1][o][k - 1];
          } else
            dp[i][j][k] += dp[i - 1][o][k];
        }
      }
    }
  }
  fac[0] = 1;
  for (int i = 1; i < N; ++i) fac[i] = fac[i - 1] * i;
  scanf("%d", &m);
  for (int k = 0; k <= 10; ++k) {
    f[k] = cal(m, k);
  }
  long long o = 0;
  for (int k = 1; k <= 10; ++k) {
    sum = 0;
    for (int s = 0; s < k; ++s) {
      dfs(s);
    }
    o += f[k] * sum;
    o %= Mod;
  }
  cout << o << endl;
  return 0;
}