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 double EPS = 1e-9;
const double PI = acos(-1.0);
const int MOD = 1000000007;
using namespace std;
bool luck(int x) { return x == 7 || x == 4; }
int dp[12][12][3];
int d[12];
int m[10];
int lenm;
int add(int a, int b) {
  a += b;
  while (a > MOD) a -= MOD;
  return a;
}
int mul(int a, int b) {
  long long M = 1LL * a * b;
  M %= (long long)MOD;
  return (int)M;
}
int go(int i, int cnt) {
  if (i == 6) return 1;
  int res = 0;
  for (int c = 0; c < cnt; c++) {
    d[c]--;
    res = add(res, mul(d[c] + 1, go(i + 1, cnt - c)));
    d[c]++;
  }
  return res;
}
int main() {
  int M;
  scanf("%d", &M);
  lenm = 0;
  while (M > 0) {
    m[lenm++] = M % 10;
    M /= 10;
  }
  reverse(m, m + lenm);
  memset(dp, 0, sizeof dp);
  memset(d, 0, sizeof d);
  if (m[0] == 7 && lenm == 1) {
    dp[1][0][0] = 4;
    dp[1][1][0] = 1;
    dp[1][1][1] = 1;
    dp[1][0][1] = 1;
  } else {
    for (int i = 1; i < m[0]; i++) dp[1][luck(i)][0]++;
    dp[1][luck(m[0])][1]++;
    for (int i = m[0] + 1; i < 10; i++) dp[1][luck(i)][2]++;
  }
  for (int len = 1; len <= lenm; len++)
    for (int cnt = 0; cnt <= len; cnt++)
      for (int e = 0; e < 3; e++) {
        if (len < lenm || e <= 1) d[cnt] += dp[len][cnt][e];
        for (int next = 0; next < 10; next++) {
          int ncnt = cnt + (luck(next));
          int ne;
          if (e == 1) {
            if (next == m[len])
              ne = 1;
            else if (next < m[len])
              ne = 0;
            else
              ne = 2;
          } else
            ne = e;
          dp[len + 1][ncnt][ne] += dp[len][cnt][e];
        }
      }
  int res = 0;
  for (int cnt = 1; cnt <= 9; cnt++) {
    d[cnt]--;
    res = add(res, mul(d[cnt] + 1, go(0, cnt)));
    d[cnt]++;
  }
  printf("%d\n", res);
  return 0;
}