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 <typename typ>
void vout(vector<typ>& v) {
  for (int vint = 0; vint < (int)(v).size(); vint++) cout << (v)[vint] << ' ';
  cout << endl;
}
template <typename typ>
void arrout(typ* arr, int l) {
  for (int i = 0; i < l; i++) cout << arr[i] << ' ';
  cout << endl;
}
long long int m;
long long mod = (long long)1e9 + 7;
long long int nL[10];
long long int cal_nL(long long int, int);
long long int pow_mod(int, long long int);
int C[10][10];
vector<vector<vector<int> > > partitions;
void set_partitions(int);
long long int sum_luck(int);
int main() {
  memset(C, 0, sizeof(C));
  C[0][0] = 1;
  for (int n = 1; n < 10; ++n) {
    C[n][0] = 1;
    for (int k = 1; k <= n; ++k) C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
  }
  cin >> m;
  for (int i = 0; i < 10; ++i) nL[i] = cal_nL(m, i);
  nL[0] -= 1;
  partitions.resize(9, vector<vector<int> >());
  partitions[0].resize(1, vector<int>(6, 0));
  for (int i = 1; i < 9; ++i) set_partitions(i);
  long long int ans = 0;
  long long int sum_of_luck[9];
  for (int i = 0; i < 9; ++i) {
    sum_of_luck[i] = sum_luck(i);
    if (i) sum_of_luck[i] = (sum_of_luck[i] + sum_of_luck[i - 1]) % mod;
  }
  for (int luck = 1; luck < 10; ++luck) {
    ans += (nL[luck] * sum_of_luck[luck - 1]) % mod;
    ans %= mod;
  }
  cout << (ans) << endl;
}
void set_partitions(int n) {
  vector<int> p(6, 0);
  for (p[0] = 0; p[0] <= n; ++p[0])
    for (p[1] = p[0]; p[1] + p[0] <= n; ++p[1])
      for (p[2] = p[1]; p[1] + p[2] + p[0] <= n; ++p[2])
        for (p[3] = p[2]; p[0] + p[1] + p[2] + p[3] <= n; p[3]++)
          for (p[4] = p[3]; p[4] + p[0] + p[1] + p[2] + p[3] <= n; ++p[4]) {
            p[5] = n - p[1] - p[2] - p[0] - p[3] - p[4];
            if (p[5] >= p[4]) partitions[n].push_back(p);
          }
}
long long int sum_luck(int luck) {
  long long int ans = 0;
  for (int i = 0; i < (int)(partitions[luck]).size(); ++i) {
    vector<int> count(9, 0);
    for (int j = 0; j < (int)(partitions[luck][i]).size(); ++j)
      count[partitions[luck][i][j]]++;
    long long int temp = 1;
    bool flag = false;
    int t = 6;
    for (int c = 0; c < 9; ++c) {
      temp *= C[t][count[c]];
      temp %= mod;
      t -= count[c];
      for (int k = 0; k < count[c]; ++k) {
        if (nL[c] - k > 0)
          temp = (temp * (nL[c] - k)) % mod;
        else {
          flag = true;
          break;
        }
      }
    }
    if (!flag) ans = (ans + temp) % mod;
  }
  return ans;
}
long long int cal_nL(long long int lim, int rem) {
  if (!lim) return !rem;
  long long int temp = lim;
  long long int p = 1;
  while (temp) {
    p *= 10;
    temp /= 10;
  }
  p /= 10;
  int dig = lim / p;
  long long int ans =
      (dig - (dig > 4 ? 1 : 0) - (dig > 7 ? 1 : 0)) * cal_nL(p - 1, rem);
  if (rem)
    ans += ((dig > 4 ? 1 : 0) + (dig > 7 ? 1 : 0)) * cal_nL(p - 1, rem - 1);
  if (dig != 4 && dig != 7)
    ans += cal_nL(lim % p, rem);
  else if (rem)
    ans += cal_nL(lim % p, rem - 1);
  return ans;
}