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;
long long calcNumber(int, int, int);
long long dp(int, int, int);
long long comb(long long, long long);
long long MEMO[12][12][2];
long long C[12];
long long memo[12][12][12];
long long F[10];
int S[12];
int L;
int main() {
  memset(MEMO, -1, sizeof MEMO);
  memset(memo, -1, sizeof memo);
  memset(C, 0, sizeof C);
  F[0] = 1LL;
  for (int i = 1; i < 10; i++) F[i] = (F[i - 1] * i) % 1000000007LL;
  string linea;
  cin >> linea;
  L = linea.size();
  for (int i = 0; i < L; i++) S[i] = linea[i] - '0';
  for (int i = 0; i < 11; i++) {
    C[i] = calcNumber(i, 0, true);
  }
  C[0]--;
  long long ans = 0LL;
  for (int s = 1; s < 11; s++)
    ans = (ans + dp(0, 6, s - 1) * C[s]) % 1000000007LL;
  cout << ans << endl;
  return 0;
}
long long calcNumber(int x, int l, int e) {
  long long &ret = MEMO[x][l][e];
  if (ret != -1LL) return ret;
  if (l == L) {
    if (x == 0) return ret = 1LL;
    return ret = 0LL;
  }
  ret = 0;
  if (e) {
    for (int k = 0; k <= S[l]; k++) {
      if (k == 4 or k == 7) {
        if (x) ret += calcNumber(x - 1, l + 1, k == S[l]);
      } else
        ret += calcNumber(x, l + 1, k == S[l]);
    }
  } else {
    for (int k = 0; k <= 9; k++) {
      if (k == 4 or k == 7) {
        if (x) ret += calcNumber(x - 1, l + 1, false);
      } else
        ret += calcNumber(x, l + 1, false);
    }
  }
  return ret;
}
long long dp(int p, int x, int sum) {
  long long &ret = memo[p][x][sum];
  if (ret != -1LL) return ret;
  if (p == 11) {
    if (x == 0) {
      return ret = 1LL;
    } else {
      return ret = 0LL;
    }
  }
  ret = 0LL;
  int limite;
  if (p == 0) {
    limite = min((long long)x, C[p]);
  } else {
    limite = min((long long)min(x, sum / p), C[p]);
  }
  for (int y = 0; y <= limite; y++) {
    long long tmp = 1LL;
    for (int i = 0; i < y; i++) tmp = (tmp * (C[p] - i)) % 1000000007LL;
    ret = (ret +
           ((comb(x, y) * tmp) % 1000000007LL * dp(p + 1, x - y, sum - y * p)) %
               1000000007LL) %
          1000000007LL;
  }
  return ret;
}
long long comb(long long n, long long x) {
  if (n == 0LL) return 1LL;
  if (x == 0LL) return 1LL;
  if (n == x) return 1LL;
  long long ans = 1;
  for (long long y = 1LL; y <= x; y++) {
    ans = ((ans * (n - y + 1LL)) / (y)) % 1000000007LL;
  }
  return ans;
}