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>
int any_table[11][11];
struct DammedPascalNUmber {
  int tb[13][13];
  DammedPascalNUmber() {
    int i, j;
    for (i = 0; i <= 12; i++)
      for (j = 0; j <= i; j++) {
        int &r = tb[i][j];
        if (j == 0 || i == 0)
          r = 1;
        else
          r = tb[i - 1][j - 1] + tb[i - 1][j];
      }
  }
  int count(int n, int m) { return tb[n][m]; }
} pas;
int any(int dig, int amo) {
  if (dig < amo) return 0;
  if (amo < 0) return 0;
  if (dig == 0) return 1;
  int &r = any_table[dig][amo];
  int i;
  if (r >= 0) return r;
  r = 1;
  for (i = 0; i < amo; i++) r *= 2;
  for (; i < dig; i++) r *= 8;
  r *= pas.count(dig, amo);
  return r;
}
int check(int m, int n) {
  int i, j, t, r = 0;
  for (i = 1; i <= m; i++) {
    char str[15];
    t = 0;
    sprintf(str, "%d", i);
    for (j = 0; str[j]; j++)
      if (str[j] == '4' || str[j] == '7') t++;
    if (t == n) r++;
  }
  return r;
}
int a[13];
int dfs(int party, int quta) {
  int r = 0, i;
  if (party == 6) {
    return 1;
  }
  for (i = quta; i >= 0; i--)
    if (a[i] > 0) {
      int t = a[i];
      a[i]--;
      r = (1LL * r + 1LL * t * 1LL * dfs(party + 1, quta - i) +
           1LL * 1000000007) %
          1000000007;
      a[i]++;
    }
  return r;
}
void test(int n, int m) { printf("any(%d,%d)=%d\n", n, m, any(n, m)); }
void test2(int m, int n) {
  printf("(%d,%d)=%d a[%d]=%d\n", m, n, check(m, n), n, a[n]);
}
int main() {
  memset(any_table, -1, sizeof(any_table));
  int m, s, i, j, k, sn, lucked;
  while (~scanf("%d", &m)) {
    memset(a, 0, sizeof(a));
    char str[15];
    sprintf(str, "%d", m);
    for (sn = 0; str[sn]; sn++)
      ;
    for (j = sn; j > 0; j--) {
      a[j] = 0;
      lucked = 0;
      for (i = 0; i < sn; i++) {
        int p = 0, q = 0;
        k = str[i] - '0' - 1;
        for (; k >= 0; k--)
          if (k == 4 || k == 7)
            q++;
          else
            p++;
        if (p) a[j] += p * any(sn - i - 1, j - lucked);
        if (q) a[j] += q * any(sn - i - 1, j - lucked - 1);
        if (str[i] == '4' || str[i] == '7') {
          lucked++;
        }
        if (i == sn - 1 && lucked == j) a[j]++;
      }
    }
    a[0] = m;
    for (i = 1; i <= sn; i++) a[0] -= a[i];
    int ans = 0;
    for (i = 1; i <= sn; i++)
      if (a[i]) {
        ans = (1LL * ans + 1LL * a[i] * dfs(0, i - 1) + 1LL * 1000000007) %
              1000000007;
      }
    printf("%d\n", ans);
  }
}