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;
char buf[32];
int ps[32];
int ctable[16][16];
int fac7[16];
const int MOD = 1000000007;
long long int pp(long long int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    b >>= 1;
    a = a * a % MOD;
  }
  return ret;
}
int table[16][16][16];
long long int func(int pos, int r, int total) {
  if (total <= 0)
    return 0;
  else if (r == 0)
    return 1;
  else if (pos < 0)
    return 0;
  else if (table[pos][r][total])
    return table[pos][r][total] - 1;
  else {
    int& v = table[pos][r][total];
    int tmp = 1;
    for (int i = 0; i <= r && i <= ps[pos]; i++) {
      (v += func(pos - 1, r - i, total - pos * i) * tmp % MOD * ctable[r][i] %
            MOD) %= MOD;
      tmp = tmp * (long long int)(ps[pos] - i) % MOD;
    }
    return v++;
  }
}
int main() {
  for (int i = 0; i < 16; i++)
    for (int j = ctable[i][0] = ctable[i][i] = 1; j < i; j++)
      ctable[i][j] = (ctable[i - 1][j] + ctable[i - 1][j - 1]) % MOD;
  fac7[0] = 1;
  for (int i = 1; i < 16; i++) fac7[i] = fac7[i - 1] * 8ll % MOD;
  scanf("%s", buf);
  int len = strlen(buf);
  int alc = 0;
  for (int i = 0; buf[i]; i++) {
    for (int k = '0'; k < buf[i]; k++)
      for (int l = 0; l <= len - 1 - i; l++)
        (ps[alc + (k == '4' || k == '7') + l] +=
         ctable[len - i - 1][l] * (1ll << l) % MOD * fac7[len - i - 1 - l] %
         MOD) %= MOD;
    alc += (buf[i] == '4' || buf[i] == '7');
  }
  ps[0]--;
  ps[alc]++;
  ps[alc] %= MOD;
  int ans = 0;
  for (int i = 1; i < 16; i++) (ans += func(i - 1, 6, i) * ps[i] % MOD) %= MOD;
  printf("%d\n", ans);
  return 0;
}