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 double PI = acos(-1.0);
const int mod = 1000000007;
int D[10][10] = {0};
void init() {
  D[0][0] = 1;
  for (int n = (1), en = (10); n < en; n++) {
    for (int d = (0), ed = (10); d < ed; d++) {
      if (d != 4 && d != 7) {
        D[n][0] += D[n - 1][0];
        for (int k = (1), ek = (10); k < ek; k++) D[n][k] += D[n - 1][k];
      } else {
        for (int k = (1), ek = (10); k < ek; k++) D[n][k] += D[n - 1][k - 1];
      }
    }
  }
}
int calcCnt(int m, int need) {
  char str[20];
  sprintf(str, "%d", m);
  int l = strlen(str);
  reverse(str, str + l);
  int res = 0;
  int has = 0;
  for (int i = l - 1; i >= 0; i--) {
    str[i] -= '0';
    if (str[i] <= 4)
      res += str[i] * D[i][need - has];
    else if (str[i] <= 7) {
      res += 4 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += (str[i] - 5) * D[i][need - has];
    } else {
      res += 4 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += 2 * D[i][need - has];
      if (need - has - 1 >= 0) res += D[i][need - has - 1];
      res += (str[i] - 8) * D[i][need - has];
    }
    if (str[i] == 4 || str[i] == 7) ++has;
    if (has > need) break;
  }
  if (has == need) ++res;
  return res;
}
long long res = 0;
int Cnt[10];
void rec(int ind, int sum, int currsum, long long currcnt) {
  if (ind == 6) {
    if (currsum < sum) res = (res + currcnt) % mod;
    return;
  }
  for (int i = (0), ei = (sum); i < ei; i++) {
    if (currsum + i < sum && Cnt[i] != 0) {
      long long was = Cnt[i];
      --Cnt[i];
      rec(ind + 1, sum, currsum + i, (currcnt * was) % mod);
      ++Cnt[i];
    }
  }
}
bool check(int m, int cnt) {
  int calc = calcCnt(m, cnt);
  if (cnt == 0) --calc;
  char str[20];
  int res = 0;
  for (int i = (1), ei = (m + 1); i < ei; i++) {
    sprintf(str, "%d", i);
    int curr = 0;
    for (int j = (0), ej = (strlen(str)); j < ej; j++)
      if (str[j] == '4' || str[j] == '7') ++curr;
    res += (curr == cnt);
  }
  return calc == res;
}
void run() {
  init();
  int m;
  cin >> m;
  for (int i = (0), ei = (10); i < ei; i++) Cnt[i] = calcCnt(m, i);
  if (Cnt[0] > 0) --Cnt[0];
  res = 0;
  for (int s = (1), es = (10); s < es; s++) {
    long long curr = Cnt[s];
    rec(0, s, 0, curr);
  }
  cout << res << endl;
}
int main() {
  run();
  return 0;
}