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>
long long gav = 0;
int n, dig, k;
int num[15];
int arr[15];
int nem[15];
int hana[15];
long long ans;
void bctr(int x, int le) {
  if (x == le) {
    long long q1 = 1, q2 = 0;
    if (le != dig) {
      for (int i = 0; i < le; i++) {
        if (nem[i] == 0) {
          if (i == 0)
            q1 *= 7;
          else
            q1 *= 8;
        } else
          q1 *= 2, q2++;
      }
    } else {
      int kel[5];
      q1 = 0;
      kel[0] = 0, kel[1] = 0;
      for (int i = 0; i < le; i++) kel[nem[i]]++;
      q2 = kel[1];
      for (int i = 0, j = le - 1; i < le; i++, j--) {
        if (nem[i] == 0) {
          int bas = 0;
          if (i == 0) bas = 1;
          kel[0]--;
          gav = 1;
          for (int jj = bas; jj < arr[j]; jj++) {
            if (jj != 4 && jj != 7) {
              gav = 1;
              for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
              for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
              q1 += gav;
            }
          }
          if (arr[j] == 4 || arr[j] == 7) break;
        } else {
          kel[1]--;
          if (arr[j] < 4) break;
          if (arr[j] > 4) {
            gav = 1;
            for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
            for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
            q1 += gav;
            if (arr[j] < 7) break;
          }
          if (arr[j] > 7) {
            gav = 1;
            for (int tt = 0; tt < kel[0]; tt++) gav *= 8;
            for (int tt = 0; tt < kel[1]; tt++) gav *= 2;
            q1 += gav;
            break;
          }
        }
      }
    }
    num[q2] += q1;
    return;
  }
  for (int i = 0; i < 2; i++) nem[x] = i, bctr(x + 1, le);
}
void tap(int x, int y) {
  if (x == 6) {
    int q5 = 0;
    for (int i = 0; i < 6; i++) q5 += hana[i];
    if (q5 >= y) return;
    int diz[15];
    for (int i = 0; i <= 10; i++) diz[i] = num[i];
    long long es = 1;
    for (int i = 0; i < 6; i++) {
      es *= diz[hana[i]];
      diz[hana[i]]--;
      es %= 1000000007;
    }
    es *= num[y];
    es %= 1000000007;
    ans += es;
    ans %= 1000000007;
    return;
  }
  for (int j = 0; j < y; j++) {
    hana[x] = j;
    tap(x + 1, y);
  }
}
int main() {
  scanf("%d", &n);
  dig = 0, k = n;
  int ba1 = 0;
  while (k > 0) {
    arr[dig] = k % 10;
    k /= 10;
    if (arr[dig] == 4 || arr[dig] == 7) ba1++;
    dig++;
  }
  for (int j = 1; j <= dig; j++) bctr(0, j);
  num[ba1]++;
  for (int j = 1; j <= 10; j++)
    if (num[j] != 0) tap(0, j);
  int kel = ans % 1000000007;
  printf("%d\n", kel);
  getchar();
  getchar();
}