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 m, l, tmax;
long long f[15][15][2], ans = 0, a[15], cnt[15], b[15], c[15], fac[7], inv[7];
void init() { scanf("%d", &m); }
long long calc(long long a, long long b) {
  if (b > a) return 0;
  int i;
  long long x = 1;
  for (i = 0; i < b; i++) x = x * (a - i) % 1000000007;
  x = x * inv[b] % 1000000007;
  return x;
}
void dfs(int step, int sum) {
  if (step == 7) {
    long long tot = 1;
    int i;
    for (i = 1; i <= tmax; i++)
      if (c[i]) tot = tot * calc(cnt[i] - cnt[i - 1], c[i]) % 1000000007;
    if (c[0]) tot = tot * calc(cnt[0], c[0]) % 1000000007;
    tot = (tot * (cnt[tmax] - cnt[sum])) % 1000000007;
    ans = (ans + tot) % 1000000007;
    return;
  }
  int i;
  for (i = b[step - 1]; i < tmax - sum; i++) {
    b[step] = i;
    c[i]++;
    dfs(step + 1, sum + i);
    c[i]--;
  }
}
long long ksm(long long x, long long y) {
  long long a = x, b = y, d = 1;
  while (b) {
    if (b & 1) d = d * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return d;
}
void work() {
  l = int(trunc(log10(m))) + 1;
  int t = m, k = l, i, j;
  while (t) {
    a[k--] = t % 10;
    t /= 10;
  }
  f[0][0][0] = 1;
  for (i = 0; i < l; i++)
    for (j = 0; j <= i; j++)
      for (k = 0; k <= 1; k++)
        if (f[i][j][k]) {
          if (k) {
            f[i + 1][j][k] =
                (f[i + 1][j][k] + f[i][j][k] * 8 % 1000000007) % 1000000007;
            f[i + 1][j + 1][k] =
                (f[i + 1][j + 1][k] + f[i][j][k] * 2 % 1000000007) % 1000000007;
          } else {
            if (a[i + 1] == 4 || a[i + 1] == 7)
              f[i + 1][j + 1][k] =
                  (f[i + 1][j + 1][k] + f[i][j][k]) % 1000000007;
            else
              f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % 1000000007;
            if (a[i + 1] >= 8) {
              f[i + 1][j + 1][1] =
                  (f[i + 1][j + 1][1] + f[i][j][k] * 2 % 1000000007) %
                  1000000007;
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * (a[i + 1] - 2) % 1000000007) %
                  1000000007;
            } else if (a[i + 1] >= 5) {
              f[i + 1][j + 1][1] =
                  (f[i + 1][j + 1][1] + f[i][j][k]) % 1000000007;
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * (a[i + 1] - 1) % 1000000007) %
                  1000000007;
            } else
              f[i + 1][j][1] =
                  (f[i + 1][j][1] + f[i][j][k] * a[i + 1] % 1000000007) %
                  1000000007;
          }
        }
  for (i = 0; i <= l; i++) cnt[i] = (f[l][i][0] + f[l][i][1]) % 1000000007;
  cnt[0] -= 1;
  tmax = l;
  while (!cnt[tmax] && tmax) tmax--;
  if (!tmax) {
    puts("0");
    return;
  }
  for (i = 1; i <= tmax; i++) cnt[i] = (cnt[i - 1] + cnt[i]) % 1000000007;
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = 1;
  for (i = 2; i <= 6; i++) {
    fac[i] = fac[i - 1] * i;
    inv[i] = ksm(fac[i], 1000000007 - 2);
  }
  dfs(1, 0);
  cout << (ans * 720) % 1000000007 << endl;
}
int main() {
  init();
  work();
  return 0;
}