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 long long int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
vector<long long int> no;
vector<vector<vector<long long int>>> dp(
    12, vector<vector<long long int>>(12, vector<long long int>(2, 0)));
void fun() {
  long long int indd = (long long int)(no.size()) - 1;
  dp[indd][0][1] = 8;
  dp[indd][1][1] = 2;
  for (long long int i = 0; i <= no[indd]; i++) {
    long long int req = 0;
    if (i == 4 || i == 7) {
      req = 1;
    }
    dp[indd][req][0]++;
  }
  for (long long int ind = (long long int)(no.size()) - 2; ind >= 0; ind--) {
    for (long long int req = 0; req <= 9; req++) {
      for (long long int less = 0; less <= 1; less++) {
        long long int higher;
        if (less == 0) {
          higher = no[ind];
        } else {
          higher = 9;
        }
        for (long long int x = 0; x <= higher; x++) {
          long long int new_req = req;
          if (x == 4 || x == 7) {
            new_req--;
          }
          long long int ch = (x < no[ind]);
          long long int new_less = (less | ch);
          if (new_req >= 0) {
            dp[ind][req][less] += dp[ind + 1][new_req][new_less];
            dp[ind][req][less] %= MOD;
          }
        }
      }
    }
  }
}
void solve() {
  long long int m;
  cin >> m;
  long long int tmp = m;
  while (tmp > 0) {
    no.push_back(tmp % 10);
    tmp /= 10;
  }
  reverse(no.begin(), no.end());
  fun();
  map<long long int, long long int> mp;
  long long int tot = 0;
  for (long long int i = 1; i <= 9; i++) {
    mp[i] = dp[0][i][0];
    tot += dp[0][i][0];
  }
  mp[0] = m - tot;
  long long int ans = 0;
  for (long long int i = 1; i <= 9; i++) {
    vector<long long int> tmp;
    tmp.push_back(mp[i]);
    mp[i]--;
    for (long long int a = 0; a <= 9; a++) {
      tmp.push_back(mp[a]);
      mp[a]--;
      for (long long int b = 0; b < i; b++) {
        tmp.push_back(mp[b]);
        mp[b]--;
        for (long long int c = 0; c < i; c++) {
          tmp.push_back(mp[c]);
          mp[c]--;
          for (long long int d = 0; d < i; d++) {
            tmp.push_back(mp[d]);
            mp[d]--;
            for (long long int e = 0; e < i; e++) {
              tmp.push_back(mp[e]);
              mp[e]--;
              for (long long int f = 0; f < i; f++) {
                tmp.push_back(mp[f]);
                mp[f]--;
                long long int calc = a + b + c + d + e + f;
                if (i > calc) {
                  long long int no = 1;
                  for (long long int j = 0; j < (long long int)(tmp.size());
                       j++) {
                    no *= tmp[j];
                    no %= MOD;
                  }
                  ans += no;
                  ans %= MOD;
                }
                tmp.pop_back();
                mp[f]++;
              }
              tmp.pop_back();
              mp[e]++;
            }
            tmp.pop_back();
            mp[d]++;
          }
          tmp.pop_back();
          mp[c]++;
        }
        tmp.pop_back();
        mp[b]++;
      }
      tmp.pop_back();
      mp[a]++;
    }
    tmp.pop_back();
    mp[i]++;
  }
  cout << ans << "\n";
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}