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 int P = 1000000007;
char s[14];
int n, ans, A[11], cnt[11], J[11], V[11], len, lw, f[11][11][11];
bool ok, B[11][11];
void fly(int x, int d, bool fl) {
  if (fl) {
    memset(f[x][d], 0, sizeof(f[x][d]));
    B[x][d] = false;
  }
  if (d > lw + 1) return;
  if (B[x][d]) return;
  if (d == lw + 1) f[x][d][(x == 4 || x == 7)] = 1;
  B[x][d] = true;
  if (fl)
    for (int i = 0; i <= s[d] - '0'; ++i) {
      fly(i, d + 1, i == (s[d] - '0'));
      for (int j = 0; j <= 9; ++j)
        f[x][d][j + (x == 4 || x == 7)] =
            (f[x][d][j + (x == 4 || x == 7)] + f[i][d + 1][j]) % P;
    }
  else
    for (int i = 0; i <= 9; ++i) {
      fly(i, d + 1, false);
      for (int j = 0; j <= 9; ++j)
        f[x][d][j + (x == 4 || x == 7)] =
            (f[x][d][j + (x == 4 || x == 7)] + f[i][d + 1][j]) % P;
    }
}
int Pow(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1LL * res * x % P;
    x = 1LL * x * x % P;
    k >>= 1;
  }
  return res;
}
int C(int n, int m) {
  int res = 1;
  for (int i = 1; i <= m; ++i) {
    res = 1LL * res * (n - i + 1) % P;
    res = 1LL * res * V[i] % P;
  }
  return res;
}
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  sscanf(s + 1, "%d", &n);
  for (lw = 1; lw < len; ++lw) {
    for (int i = 1; i <= 9; ++i) {
      memset(B, false, sizeof(B));
      memset(f, 0, sizeof(f));
      fly(i, 2, false);
      for (int j = 0; j <= 9; ++j) A[j] += f[i][2][j];
    }
  }
  for (int i = 1; i <= s[1] - '0'; ++i) {
    memset(B, false, sizeof(B));
    memset(f, 0, sizeof(f));
    fly(i, 2, i == s[1] - '0');
    for (int j = 0; j <= 10; ++j) A[j] += f[i][2][j];
  }
  for (int i = 1; i <= 10; ++i) V[i] = Pow(i, P - 2);
  V[0] = J[0] = 1;
  for (int i = 1; i <= 10; ++i) J[i] = 1LL * J[i - 1] * i % P;
  for (int g = 1; g <= 9; ++g)
    for (int j = 0; j <= g - 1; ++j)
      for (int a = 0; a <= j; ++a)
        for (int b = 0; b <= j - a; ++b)
          for (int c = 0; c <= j - a - b; ++c)
            for (int d = 0; d <= j - a - b - c; ++d)
              for (int e = 0; e <= j - a - b - c - d; ++e) {
                int f = j - a - b - c - d - e;
                int res = 1;
                ++cnt[a];
                ++cnt[b];
                ++cnt[c];
                ++cnt[d];
                ++cnt[e];
                ++cnt[f];
                ++cnt[g];
                ok = true;
                for (int k = 0; k <= g; ++k)
                  if (cnt[k] > A[k]) {
                    ok = false;
                    break;
                  } else
                    res = 1LL * res * C(A[k], cnt[k]) % P * J[cnt[k]] % P;
                if (ok) ans = (ans + res) % P;
                --cnt[a];
                --cnt[b];
                --cnt[c];
                --cnt[d];
                --cnt[e];
                --cnt[f];
                --cnt[g];
              }
  printf("%d\n", ans);
  return 0;
}