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, -1)));
long long int fun(long long int ind, long long int req, bool less) {
  if (ind >= (long long int)(no.size())) {
    if (req == 0) {
      return 1;
    } else {
      return 0;
    }
  }
  if (req < 0) {
    return 0;
  }
  if (dp[ind][req][less] != -1) {
    return dp[ind][req][less];
  }
  long long int higher;
  if (less == 1) {
    higher = 9;
  } else {
    higher = no[ind];
  }
  long long int val = 0;
  for (long long int i = 0; i <= higher; i++) {
    bool check_current = (i < no[ind]);
    bool new_less = (less | check_current);
    if (i == 4 || i == 7) {
      val += fun(ind + 1, req - 1, new_less);
      val %= MOD;
    } else {
      val += fun(ind + 1, req, new_less);
      val %= MOD;
    }
  }
  dp[ind][req][less] = val;
  return dp[ind][req][less];
}
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());
  for (long long int i = 1; i <= (long long int)(no.size()); i++) {
    fun(0, i, 0);
  }
  map<long long int, long long int> mp;
  long long int tot = 0;
  for (long long int i = 1; i <= 9; i++) {
    if (dp[0][i][0] < 0) {
      dp[0][i][0] = 0;
    }
    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;
}