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;
vector<vector<pair<int, int> > > getMasks(string pattern) {
  vector<vector<pair<int, int> > > results;
  for (int j = ((int)pattern.size()) - 1; j >= 0; j--) {
    vector<pair<int, int> > curpat;
    bool flag = false;
    for (int k = 0; k < j; k++) {
      int dig = pattern[k] - '0';
      curpat.push_back(pair<int, int>(dig, dig));
    }
    if (pattern[j] == '0') {
      flag = true;
      continue;
    }
    int dig = pattern[j] - '1';
    curpat.push_back(pair<int, int>(0, dig));
    for (int k = j + 1; k < ((int)pattern.size()); k++)
      curpat.push_back(pair<int, int>(0, 9));
    if (curpat[0].first == 0 && curpat[0].second == 0)
      curpat.erase(curpat.begin());
    bool flag2 = true;
    results.push_back(curpat);
  }
  vector<pair<int, int> > curpat;
  for (int i = 0; i < ((int)pattern.size()); i++) {
    int dig = pattern[i] - '0';
    curpat.push_back(pair<int, int>(dig, dig));
  }
  results.push_back(curpat);
  return results;
}
long long countways(vector<pair<int, int> > &pat, int pos, int luckleft) {
  if (pos == ((int)pat.size()) && luckleft == 0)
    return 1LL;
  else if (pos == ((int)pat.size()))
    return 0LL;
  long long digs = (long long)pat[pos].second - pat[pos].first + 1;
  long long ldigs = 0LL;
  if (pat[pos].first <= 4 && pat[pos].second >= 4) ldigs++;
  if (pat[pos].first <= 7 && pat[pos].second >= 7) ldigs++;
  long long res = 0LL;
  if (luckleft > 0)
    res =
        ((long long)ldigs * countways(pat, pos + 1, luckleft - 1)) % 1000000007;
  res =
      (res + (((long long)(digs - ldigs) * countways(pat, pos + 1, luckleft)) %
              1000000007)) %
      1000000007;
  return res;
}
long long nways[10];
long long count2(vector<int> counts, int limit, int left) {
  int sum = accumulate(counts.begin(), counts.end(), 0);
  if (sum == 6) return 1LL;
  long long res = 0LL;
  for (int i = 0; i < limit && left >= i; i++) {
    vector<int> copy(counts);
    copy[i]++;
    res = (res +
           (((long long)nways[i] - counts[i]) * count2(copy, limit, left - i)) %
               1000000007) %
          1000000007;
  }
  return res;
}
int main() {
  string pattern;
  cin >> pattern;
  vector<vector<pair<int, int> > > masks = getMasks(pattern);
  memset(nways, 0LL, sizeof(nways));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < ((int)masks.size()); j++) {
      nways[i] = (nways[i] + countways(masks[j], 0, i)) % 1000000007;
    }
  }
  nways[0]--;
  long long finalresult = 0LL;
  for (int i = 1; i < 10; i++) {
    vector<int> seed(i, 0);
    finalresult =
        (finalresult + (nways[i] * count2(seed, i, i - 1)) % 1000000007) %
        1000000007;
  }
  cout << finalresult << endl;
  return 0;
}