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;
long long f[20][20][20], n[20], ans, z, l;
char s[20];
void get() {
  long long i, j, k, k2;
  f[0][0][0] = 1;
  for (i = 1; i <= 10; i++) {
    for (j = 0; j <= 10; j++) {
      for (k = 0; k <= 9; k++) {
        if (k == 4 || k == 7) {
          for (k2 = 0; k2 <= 9; k2++) {
            f[k][i][j] += f[k2][i - 1][j - 1];
          }
        } else {
          for (k2 = 0; k2 <= 9; k2++) {
            f[k][i][j] += f[k2][i - 1][j];
          }
        }
      }
    }
  }
}
int main() {
  long long i, j, j1, j2, j3, j4, j5, j6, k, k1, k2, k3, k4, k5, k6;
  get();
  scanf("%s", s + 1);
  l = strlen(s + 1);
  for (i = l; i >= 1; i--) {
    if (s[i] - 48 == 4 || s[i] - 48 == 7) z++;
  }
  n[z]++;
  long long x = 0;
  for (i = 0; i <= 10; i++) {
    x = 0;
    for (j = 1; j <= l; j++) {
      for (k = 0; k <= s[j] - 49; k++) {
        n[i + x] += f[k][l - j + 1][i];
      }
      if (s[j] - 48 == 4 || s[j] - 48 == 7) x++;
    }
    if (n[i] == 0) break;
  }
  n[0]--;
  for (i = 1; i <= 10; i++) {
    long long an = 1;
    if (n[i]) {
      an *= n[i];
      an %= 1000000007;
      z = i - 1;
      for (j1 = 0; j1 <= z; j1++) {
        if (n[j1] == 0) continue;
        k1 = an;
        z -= j1;
        an *= n[j1];
        an %= 1000000007;
        n[j1]--;
        for (j2 = 0; j2 <= z; j2++) {
          if (n[j2] == 0) continue;
          k2 = an;
          z -= j2;
          an *= n[j2];
          an %= 1000000007;
          n[j2]--;
          for (j3 = 0; j3 <= z; j3++) {
            if (n[j3] == 0) continue;
            k3 = an;
            z -= j3;
            an *= n[j3];
            an %= 1000000007;
            n[j3]--;
            for (j4 = 0; j4 <= z; j4++) {
              if (n[j4] == 0) continue;
              k4 = an;
              z -= j4;
              an *= n[j4];
              an %= 1000000007;
              n[j4]--;
              for (j5 = 0; j5 <= z; j5++) {
                if (n[j5] == 0) continue;
                k5 = an;
                z -= j5;
                an *= n[j5];
                an %= 1000000007;
                n[j5]--;
                for (j6 = 0; j6 <= z; j6++) {
                  if (n[j6] == 0) continue;
                  k6 = an;
                  an *= n[j6];
                  an %= 1000000007;
                  ans += an;
                  ans %= 1000000007;
                  an = k6;
                }
                an = k5;
                n[j5]++;
                z += j5;
              }
              an = k4;
              n[j4]++;
              z += j4;
            }
            an = k3;
            n[j3]++;
            z += j3;
          }
          an = k2;
          n[j2]++;
          z += j2;
        }
        an = k1;
        n[j1]++;
        z += j1;
      }
    } else
      break;
  }
  cout << ans;
}