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;
int const MX = 10;
long long const MODULE = 1000000007LL;
int ms[100];
long long real_cnt[100];
long long ans = 0;
long long A(long long n, long long k) {
  if (n < k) return 0;
  long long ans = 1;
  for (long long i = n; i > n - k; i--) ans = (ans * i) % MODULE;
  return ans % MODULE;
}
long long rec(char *st, int from, int n, int c4, int c7, int is_eq) {
  int rem = n - from;
  if (c4 + c7 > rem) return 0;
  if (from >= n) return 1;
  long long ans = 0;
  int ch = st[from] - '0';
  if (is_eq) {
    int cnt_other = 0;
    int cnt_4 = 0;
    int cnt_7 = 0;
    for (int i = 0; i < ch; i++)
      if (i != 4 && i != 7)
        cnt_other++;
      else if (i == 4)
        cnt_4++;
      else if (i == 7)
        cnt_7++;
    ans += cnt_other * rec(st, from + 1, n, c4, c7, 0);
    if (c4) ans += cnt_4 * rec(st, from + 1, n, c4 - cnt_4, c7, 0);
    if (c7) ans += cnt_7 * rec(st, from + 1, n, c4, c7 - cnt_7, 0);
    if (ch == 4) {
      if (c4) ans += rec(st, from + 1, n, c4 - 1, c7, 1);
    } else if (ch == 7) {
      if (c7) ans += rec(st, from + 1, n, c4, c7 - 1, 1);
    } else
      ans += rec(st, from + 1, n, c4, c7, 1);
  } else {
    int cnt_other = 0;
    int cnt_4 = 0;
    int cnt_7 = 0;
    for (int i = 0; i <= 9; i++)
      if (i != 4 && i != 7)
        cnt_other++;
      else if (i == 4)
        cnt_4++;
      else if (i == 7)
        cnt_7++;
    ans += cnt_other * rec(st, from + 1, n, c4, c7, 0);
    if (c4) ans += cnt_4 * rec(st, from + 1, n, c4 - cnt_4, c7, 0);
    if (c7) ans += cnt_7 * rec(st, from + 1, n, c4, c7 - cnt_7, 0);
  }
  return ans;
}
long long calc(int x, int c4, int c7) {
  char st[100];
  sprintf(st, "%d", x);
  int n = (int)strlen(st);
  long long d = rec(st, 0, n, c4, c7, 1);
  return d - (c4 + c7 == 0);
}
int slow_calc(int x, int c4, int c7) {
  int ans = 0;
  for (int i = 1; i <= x; i++) {
    int y = i;
    int cur_4 = 0, cur_7 = 0;
    while (y) {
      cur_4 += (y % 10) == 4;
      cur_7 += (y % 10) == 7;
      y /= 10;
    }
    if (cur_4 == c4 && cur_7 == c7) ans++;
  }
  return ans;
}
int main() {
  int m;
  scanf("%d", &m);
  for (int c4 = 0; c4 <= MX; c4++)
    for (int c7 = 0; c7 <= MX; c7++) real_cnt[c4 + c7] += calc(m, c4, c7);
  for (int cnt = 0; cnt <= MX; cnt++)
    for (int a = 0; a <= MX && a < cnt; a++)
      for (int b = 0; b <= MX && a + b < cnt; b++)
        for (int c = 0; c <= MX && a + b + c < cnt; c++)
          for (int d = 0; d <= MX && a + b + c + d < cnt; d++)
            for (int e = 0; e <= MX && a + b + c + d + e < cnt; e++)
              for (int q = 0; q <= MX && a + b + c + d + e + q < cnt; q++) {
                for (int i = 0; i <= MX; i++) ms[i] = 0;
                ms[cnt]++;
                ms[a]++;
                ms[b]++;
                ms[c]++;
                ms[d]++;
                ms[e]++;
                ms[q]++;
                long long g = 1;
                for (int i = 0; i <= MX; i++)
                  g = (g * A(real_cnt[i], ms[i])) % MODULE;
                ans = (ans + g) % MODULE;
              }
  cout << ans;
  return 0;
}