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;
long long dp[20];
long long sum[20];
long long a[100];
long long POW(long long n, long long k) {
  if (k < 0) return 0;
  if (k == 0) return 1;
  long long res = POW(n, k / 2);
  res = (res * res) % 1000000007ll;
  if (k % 2 == 1) res = (res * n) % 1000000007ll;
  return res % 1000000007ll;
}
long long F(long long n) {
  if (n < 0) return 0;
  long long res = 1;
  for (long long i = 1; i <= n; i++) res = (res * i) % 1000000007ll;
  return res;
}
long long F(long long l, long long r) {
  if (l < 1) return 0;
  long long res = 1;
  for (long long i = l; i <= r; i++) res = (res * i) % 1000000007ll;
  return res;
}
long long Sum(long long l, long long r) {
  long long res = sum[r] - sum[l - 1];
  if (res < 0) res = 0;
  return res;
}
long long dfs(long long n, long long sum) {
  if (sum > 10) return 0;
  if (n > 6) return Sum(sum + 1, 10);
  long long res = 0;
  for (int i = 0; i <= 10; i++)
    if (dp[i] > 0) {
      dp[i]--;
      res += (dp[i] + 1) * dfs(n + 1, sum + i);
      res = res % 1000000007ll;
      dp[i]++;
    }
  return res;
}
int main() {
  long long n;
  cin >> n;
  long long x = n;
  int m = 0;
  while (x) {
    a[m++] = x % 10;
    x /= 10;
  }
  dp[0] = 0;
  long long ans = 0;
  for (long long i = 0; i <= 10; i++) {
    long long cnt = 0;
    for (long long x = 0; x <= i; x++) {
      long long y = i - x;
      long long xx = x, yy = y;
      for (long long j = 10; j >= 0; j--) {
        if (xx < 0 || yy < 0) break;
        int mul = a[j];
        if (a[j] > 4) mul--;
        if (a[j] > 7) mul--;
        if (j - (xx + yy) >= 0) {
          cnt += mul * POW(8, j - (xx + yy)) *
                 (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
          cnt = cnt % 1000000007ll;
        }
        if (a[j] > 4) {
          xx--;
          mul = 1;
          if (xx >= 0)
            if (j - (xx + yy) >= 0) {
              cnt += mul * POW(8, j - (xx + yy)) *
                     (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
              cnt = cnt % 1000000007ll;
            }
          xx++;
        }
        if (a[j] > 7) {
          yy--;
          mul = 1;
          if (yy >= 0)
            if (j - (xx + yy) >= 0) {
              cnt += mul * POW(8, j - (xx + yy)) *
                     (F(j) / F(xx) / F(yy) / F(j - (xx + yy)));
              cnt = cnt % 1000000007ll;
            }
          yy++;
        }
        cnt = cnt % 1000000007ll;
        if (a[j] == 4) xx--;
        if (a[j] == 7) yy--;
      }
      xx = x;
      yy = y;
      for (long long j = 10; j >= 0; j--) {
        if (a[j] == 4) xx--;
        if (a[j] == 7) yy--;
      }
      if (xx == 0 && yy == 0) cnt++;
    }
    if (i == 0) cnt--;
    dp[i] = cnt;
  }
  sum[0] = dp[0];
  for (int i = 1; i <= 10; i++) sum[i] = sum[i - 1] + dp[i];
  ans = dfs(1, 0);
  cout << ans;
  return 0;
}