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;
template <typename T>
inline T abs(T a) {
  return a < 0 ? (-a) : a;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
int Get10Cnt(long long n) {
  int res = 0;
  while (n) {
    ++res;
    n /= 10;
  }
  return res;
}
const int MAXT = 11;
const long long MOD = 1000000007;
long long tens[MAXT];
long long c[MAXT][MAXT];
long long Pow(long long x, long long y) {
  if (!y) return 1;
  long long p = Pow(x, y >> 1);
  p = (p * p);
  if (y & 1) p = (p * x);
  return p;
}
long long Mul(long long from, long long to) {
  long long res = 1;
  for (long long i = from; i <= to; ++i) {
    res = (res * i) % MOD;
  }
  return res;
}
long long AnsTen(int k, int cnt) {
  if (k < 0 || k > cnt) return 0;
  return c[cnt][k] * Pow(2, k) * Pow(8, cnt - k);
}
long long Rec(int k, long long n) {
  int cnt = Get10Cnt(n);
  if (k < 0 || k > cnt) return 0;
  if (n == 0) return k == 0;
  int last = n / tens[cnt - 1];
  int a2 = (last > 4) + (last > 7);
  int a1 = last - a2;
  return a1 * AnsTen(k, cnt - 1) + a2 * AnsTen(k - 1, cnt - 1) +
         Rec(k - (last == 4 || last == 7), n % tens[cnt - 1]);
}
int main() {
  tens[0] = 1;
  for (int i = 1; i < MAXT; ++i) {
    tens[i] = tens[i - 1] * 10;
  }
  memset((c), 0, sizeof(c));
  c[0][0] = 1;
  for (int i = 1; i < MAXT; ++i) {
    c[i][0] = 1;
    for (int j = 1; j < MAXT; ++j) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
    }
  }
  long long n;
  cin >> n;
  long long v[MAXT];
  for (int i = 0; i < (MAXT); ++i) {
    v[i] = Rec(i, n);
  }
  --v[0];
  long long ans = 0;
  int mi[6];
  int cnt[MAXT];
  for (mi[0] = 0; mi[0] < 10; ++mi[0])
    for (mi[1] = 0; mi[1] < 10; ++mi[1])
      for (mi[2] = 0; mi[2] < 10; ++mi[2])
        for (mi[3] = 0; mi[3] < 10; ++mi[3])
          for (mi[4] = 0; mi[4] < 10; ++mi[4])
            for (mi[5] = 0; mi[5] < 10; ++mi[5]) {
              long long mul = 0;
              long long s = 0;
              memset((cnt), 0, sizeof(cnt));
              for (int i = 0; i < (6); ++i) {
                s += mi[i];
                ++cnt[mi[i]];
              }
              for (int i = s + 1; i < 10; ++i) {
                mul += v[i];
              }
              for (int i = 0; i < (MAXT); ++i) {
                mul = mul * Mul(v[i] - cnt[i] + 1, v[i]) % MOD;
              }
              ans = (ans + mul) % MOD;
            }
  cout << ans << endl;
  return 0;
}