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 mod7 = 1000000007;
const long long mod9 = 1000000009;
const long long linf = 2000000000;
const long long llinf = 1000000000000000000ll;
long long cnt[11][11];
long long dp[100][11][11];
long long diff[100][11][11];
long long tot[11];
long long tot2[200];
long long XXX(long long cnt, long long x) {
  long long res = 1;
  for (long long z = 2; z <= cnt; ++z) res *= z;
  for (long long z = 2; z <= x; ++z) res /= z;
  for (long long z = 2; z <= cnt - x; ++z) res /= z;
  return res;
}
long long calc(int a, int b) {
  long long res = 1;
  for (int i = 1; i <= a - b; ++i) {
    res *= 8;
  }
  for (int i = 1; i <= b; ++i) {
    res *= 2;
  }
  return res * XXX(a, b);
}
void precalc() {
  for (int i = 0; i <= 10; ++i) {
    for (int j = 0; j <= i; ++j) {
      cnt[i][j] = calc(i, j);
    }
  }
}
void precount(int a) {
  vector<int> digs;
  do {
    digs.push_back(a % 10);
    a /= 10;
  } while (a);
  int prev = 0, rem = digs.size();
  while (!digs.empty()) {
    int next = digs.back();
    digs.pop_back();
    rem = digs.size();
    for (int i = 0; i < next; ++i) {
      for (int j = 0; j <= 9; ++j) {
        tot[j + prev + (i == 4 || i == 7)] += cnt[rem][j];
      }
    }
    if (next == 4 || next == 7) ++prev;
  }
  --tot[0];
  tot[prev]++;
}
long long calcpos(int num, int v) {
  long long res = 1;
  if (tot[v] < num) return 0;
  for (long long i = tot[v]; i > tot[v] - num; --i) res *= i, res %= mod7;
  return res;
}
int main() {
  precalc();
  int n;
  cin >> n;
  precount(n);
  long long ans = 0;
  dp[0][0][0] = 1;
  for (int i = 1; i <= 6; ++i) {
    dp[0][i][0] = calcpos(i, 0) * XXX(6, i);
    dp[0][i][0] %= mod7;
  }
  for (int sum = 0; sum <= 10; ++sum) {
    for (int alr = 0; alr <= 5; ++alr) {
      for (int num = 1; num <= 6 - alr; ++num) {
        for (int last = 0; last <= 9; ++last) {
          for (int j = last + 1; j <= 10; ++j) {
            dp[sum + num * j][alr + num][j] +=
                ((dp[sum][alr][last] * calcpos(num, j)) % mod7) *
                (XXX(6 - alr, num) % mod7);
            dp[sum + num * j][alr + num][j] %= mod7;
          }
        }
      }
    }
    for (int k = 0; k <= 10; ++k) {
      tot2[sum] += dp[sum][6][k];
      tot2[sum] %= mod7;
    }
  }
  for (int i = 1; i <= 10; ++i) {
    for (int j = 0; j < i; ++j) {
      ans += (tot2[j] * tot[i]) % mod7;
      ans %= mod7;
    }
  }
  cout << ans;
  return 0;
}