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 cnt[11];
int fac[111111], ifac[111111];
int power(int base, long long exponent) {
  int result = 1, m = base;
  while (exponent) {
    if (exponent & 1) result = ((long long)result * m) % 1000000007;
    m = ((long long)m * m) % 1000000007;
    exponent /= 2;
  }
  return result;
}
int c(int n, int k) {
  return (((long long)fac[n] * ifac[k]) % 1000000007 * ifac[n - k]) %
         1000000007;
}
int var(int n, int k) {
  int ans = 1;
  for (int i = 0; i < (k); i++) ans = ((long long)ans * (n - i)) % 1000000007;
  return ans;
}
int main(int argc, char *argv[]) {
  fac[0] = 1;
  for (int i = 0; i < (111111); i++)
    fac[i + 1] = ((long long)fac[i] * (i + 1)) % 1000000007;
  ifac[111111 - 1] = power(fac[111111 - 1], 1000000007 - 2);
  for (int i = (111111 - 2); i >= (0); i--)
    ifac[i] = ((long long)ifac[i + 1] * (i + 1)) % 1000000007;
  int M;
  scanf("%d", &M);
  int m = 1000000000, l = 0;
  for (int step = 0; step < (10); step++) {
    int n = M / m;
    for (int i = 0; i < (n); i++) {
      if (i == 4 || i == 7) l++;
      int rem = 9 - step;
      for (int i = (0); i <= (rem); i++)
        cnt[l + i] = (cnt[l + i] +
                      (long long)c(rem, i) * power(2, i) * power(8, rem - i)) %
                     1000000007;
      if (i == 4 || i == 7) l--;
    }
    if (n == 4 || n == 7) l++;
    M -= n * m;
    m /= 10;
  }
  cnt[0]--;
  cnt[l]++;
  int a[7], _cnt[10];
  int ans = 0;
  for (int first = (1); first <= (9); first++)
    if (cnt[first]) {
      for (a[0] = 0; a[0] < (first); a[0]++)
        for (a[1] = 0; a[1] < (first); a[1]++)
          for (a[2] = 0; a[2] < (first); a[2]++)
            for (a[3] = 0; a[3] < (first); a[3]++)
              for (a[4] = 0; a[4] < (first); a[4]++)
                for (a[5] = 0; a[5] < (first); a[5]++) {
                  int sum = 0;
                  for (int i = 0; i < (6); i++) sum += a[i];
                  if (sum >= first) continue;
                  for (int i = 0; i < (first); i++) _cnt[i] = 0;
                  for (int i = 0; i < (6); i++) _cnt[a[i]]++;
                  bool ok = true;
                  for (int i = 0; i < (first); i++)
                    if (_cnt[i] > cnt[i]) {
                      ok = false;
                      break;
                    }
                  if (!ok) continue;
                  int tmp = 1;
                  for (int i = 0; i < (first); i++)
                    tmp = ((long long)tmp * var(cnt[i], _cnt[i])) % 1000000007;
                  ans = (ans + (long long)cnt[first] * tmp) % 1000000007;
                }
    }
  printf("%d\n", ans);
  return 0;
}