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>
const int mod = (int)1e9 + 7;
long long power(long long a, int b) {
  long long ret = 1;
  while (b > 0) {
    if (b % 2) {
      ret *= a;
      ret %= mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ret;
}
long long inverse_mod(long long n) { return power(n, mod - 2); }
long long choose(long long n, int k) {
  if (k > n) {
    return 0;
  }
  int q = 1;
  for (int i = 1; i <= k; i++) {
    q *= i;
    q %= mod;
  }
  long long p = 1;
  for (long long i = n; i > n - k; i--) {
    p *= i;
    p %= mod;
  }
  return p * inverse_mod(q) % mod;
}
int main(void) {
  int m;
  scanf("%i", &m);
  char s[50];
  sprintf(s, "%i", m);
  int len = strlen(s);
  long long f[len + 1][len + 1][2];
  memset(f, 0, sizeof(f));
  f[0][0][1] = 1;
  for (int i = 0; i < len; i++) {
    for (int j = 0; j <= len; j++) {
      for (int eq = 0; eq <= 1; eq++) {
        long long cur = f[i][j][eq];
        for (char d = '0'; d <= '9'; d++) {
          if (eq && d > s[i]) {
            continue;
          }
          int n_eq = eq && (d == s[i]);
          int is_lucky = (d == '4' || d == '7') ? 1 : 0;
          f[i + 1][j + is_lucky][n_eq] += cur;
          f[i + 1][j + is_lucky][n_eq] %= mod;
        }
      }
    }
  }
  long long counts[len + 1];
  for (int i = 0; i <= len; i++) {
    counts[i] = f[len][i][0] + f[len][i][1];
    counts[i] %= mod;
  }
  counts[0] = (counts[0] + mod - 1) % mod;
  long long dp[len + 2][50 * len + 1][10];
  memset(dp, 0, sizeof(dp));
  dp[0][0][6] = 1;
  for (int i = 0; i <= len; i++) {
    for (int s = 0; s <= 7 * len; s++) {
      for (int r = 0; r <= 6; r++) {
        long long cur = dp[i][s][r];
        if (!cur) continue;
        for (int j = 0; j <= r; j++) {
          if (s + j * i <= 7 * len && r - j >= 0) {
            dp[i + 1][s + j * i][r - j] += cur * choose(counts[i], j) % mod;
            dp[i + 1][s + j * i][r - j] %= mod;
          }
        }
      }
    }
  }
  const int six_fact = 720;
  long long take[len + 1];
  for (int i = 0; i <= len; i++) {
    take[i] = dp[len + 1][i][0] * six_fact % mod;
  }
  long long ans = 0;
  for (int c = 1; c <= len; c++) {
    for (int i = 0; i < c; i++) {
      ans += take[i] * counts[c] % mod;
      ans %= mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}