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;
int n;
int BASE = 1e9 + 7;
long long f[11][10];
long long g[11][10];
int size = 20;
long long c[21][21];
long long d[10];
long long pow2[10];
long long pow8[10];
long long res;
long long dp[11];
long long num[10];
int cur, has;
int getLucky(string, int, int);
void calCombination();
void doit(int);
int main() {
  calCombination();
  pow2[0] = 1;
  pow8[0] = 1;
  for (int i = 1; i <= 9; i++) {
    pow2[i] = (pow2[i - 1] * 2) % BASE;
    pow8[i] = (pow8[i - 1] * 8) % BASE;
    d[i] = 7;
    for (int j = 1; j <= i - 1; j++) d[i] = d[i] * 8;
  }
  f[1][0] = 7;
  f[1][1] = 2;
  for (int ndigit = 2; ndigit <= 9; ndigit++)
    for (int lucky = 0; lucky <= ndigit; lucky++) {
      if (lucky == 0) {
        f[ndigit][lucky] = d[ndigit] % BASE;
      } else {
        f[ndigit][lucky] = (((pow2[lucky] * c[lucky - 1][ndigit - 1]) % BASE) *
                            pow8[ndigit - lucky]) %
                           BASE;
        f[ndigit][lucky] +=
            ((pow2[lucky] * c[lucky][ndigit - 1]) % BASE) * d[ndigit - lucky];
        f[ndigit][lucky] = f[ndigit][lucky] % BASE;
      }
    }
  cin >> n;
  g[0][0] = 1;
  g[1][0] = f[1][0] + 1;
  for (int ndigit = 1; ndigit <= 9; ndigit++)
    for (int lucky = 0; lucky <= ndigit; lucky++) {
      g[ndigit][lucky] = (g[ndigit - 1][lucky] + f[ndigit][lucky]) % BASE;
    }
  g[10][0] = g[9][0] + 1;
  stringstream ss;
  ss << n;
  string s = ss.str();
  for (int ndigit = 1; ndigit < s.length(); ndigit++) {
    for (int i = 0; i <= 9; i++) {
      dp[i] = (dp[i] + f[ndigit][i]) % BASE;
    }
  }
  for (int i = 0; i < s.length(); i++) {
    int cur = getLucky(s, 0, i - 1);
    int lo, hi;
    if (i == 0)
      lo = 1;
    else
      lo = 0;
    hi = s[i] - '0';
    for (int j = lo; j <= hi - 1; j++) {
      int newcur = cur;
      if (j == 4 || j == 7) newcur++;
      for (int k = 0; k <= s.length() - 1 - i; k++) {
        dp[newcur + k] = (dp[newcur + k] + g[s.length() - 1 - i][k]) % BASE;
      }
    }
  }
  dp[getLucky(s, 0, s.length() - 1)]++;
  for (int i = 1; i <= 9; i++)
    if (dp[i] > 0) {
      num[0] = dp[i];
      has = i;
      doit(1);
      num[0] = 0;
    }
  cout << res << endl;
  return 0;
}
int getLucky(string s, int l, int r) {
  if (l > r) return 0;
  int ret = 0;
  for (int i = l; i <= r; i++)
    if (s[i] == '4' || s[i] == '7') ret++;
  return ret;
}
void calCombination() {
  for (int i = 0; i <= size; i++) c[0][i] = 1;
  for (int i = 1; i <= size; i++)
    for (int j = i; j <= size; j++) {
      c[i][j] = (c[i][j - 1] + c[i - 1][j - 1]) % BASE;
    }
}
void doit(int i) {
  if (i > 6) {
    long long ret = 1;
    for (int j = 0; j <= 6; j++) {
      ret = (ret * num[j]) % BASE;
    }
    res = (res + ret) % BASE;
    return;
  }
  for (int j = 0; j < 9; j++)
    if (cur + j < has && dp[j] > 0) {
      num[i] = dp[j];
      dp[j]--;
      cur = cur + j;
      doit(i + 1);
      num[i] = 0;
      cur = cur - j;
      dp[j]++;
    }
}