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 num[15];
signed long long int fact[15], inv[15], dp[15][15][2];
bool fdp[15][15][2];
signed long long int epow(signed long long int a, signed long long int b,
                          signed long long int MOD) {
  signed long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
signed long long int minv(signed long long int a) {
  return epow(a, 1000000007 - 2, 1000000007);
}
signed long long int rec(int i, int pos, int all) {
  if (pos == 11) {
    if (i == 0)
      return 1;
    else
      return 0;
  }
  if (i < 0) return 0;
  if (fdp[i][pos][all]) return dp[i][pos][all];
  for (int n = 0; n < num[pos]; ++n) {
    if (n == 4 or n == 7)
      dp[i][pos][all] += rec(i - 1, pos + 1, 1);
    else
      dp[i][pos][all] += rec(i, pos + 1, 1);
    dp[i][pos][all] %= 1000000007;
  }
  if (num[pos] == 4 or num[pos] == 7)
    dp[i][pos][all] += rec(i - 1, pos + 1, all);
  else
    dp[i][pos][all] += rec(i, pos + 1, all);
  dp[i][pos][all] %= 1000000007;
  for (int n = num[pos] + 1; all == 1 && n <= 9; ++n) {
    if (n == 4 or n == 7)
      dp[i][pos][all] += rec(i - 1, pos + 1, 1);
    else
      dp[i][pos][all] += rec(i, pos + 1, 1);
    dp[i][pos][all] %= 1000000007;
  }
  fdp[i][pos][all] = 1;
  return dp[i][pos][all];
}
signed long long int ncr(signed long long int n, signed long long int r) {
  signed long long int ans = 1;
  for (signed long long int i = 1; i <= r; ++i) {
    ans *= (n - i + 1);
    ans %= 1000000007;
  }
  ans *= inv[r];
  ans %= 1000000007;
  return ans;
}
signed long long int ans_rec(int i, int done, int limit) {
  if (i == 11) {
    if (done == 6)
      return 1;
    else
      return 0;
  }
  if (limit < 0) return 0;
  signed long long int ans = 0;
  for (int x = 0; x + done <= 6; ++x) {
    ans += ncr(dp[i][1][0], x) *
           (ans_rec(i + 1, x + done, limit - x * i) % 1000000007);
    ans %= 1000000007;
  }
  return ans;
}
int main() {
  fact[0] = 1;
  inv[0] = 1;
  for (signed long long int i = 1; i <= 11; ++i) fact[i] = fact[i - 1] * i;
  for (signed long long int i = 1; i <= 11; ++i) inv[i] = minv(fact[i]);
  signed long long int ans = 0, m, t;
  cin >> m;
  if (m == 1000000000LL)
    m--;
  else
    dp[0][1][0]--;
  t = m;
  for (int j = 10, i = 1; i <= 10; ++i, --j) {
    num[j] = t % 10;
    t /= 10;
  }
  for (int i = 0; i <= 10; ++i) rec(i, 1, 0);
  for (int lit = 1; lit <= 10; ++lit) {
    ans +=
        ((dp[lit][1][0] % 1000000007) * (ans_rec(0, 0, lit - 1) % 1000000007)) %
        1000000007;
    ans %= 1000000007;
  }
  ans *= 720;
  ans %= 1000000007;
  cout << ans;
}