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;
const int MaxN = 10, Pt = 1e9 + 7;
struct InMap {
  long long x;
  int k;
};
struct OutMap {
  bool flag;
  long long cnt;
};
int MaxPos;
long long X;
long long qwr[MaxN + 5];
long long c[MaxN + 5];
long long f[MaxN + 5][MaxN + 5][MaxN + 5];
map<InMap, OutMap> Hash;
bool operator<(InMap A, InMap B) {
  if (A.x == B.x) return A.k < B.k;
  return A.x < B.x;
}
long long Get(long long X, int n, int k) {
  if (k < 0) return 0;
  if (k > n) return 0;
  if (n == 1) {
    if (k == 1) {
      if (X >= 7) return 2;
      if (X >= 4) return 1;
      return 0;
    } else {
      if (X >= 7) return X - 1;
      if (X >= 4) return X;
      return X + 1;
    }
  }
  InMap temp;
  temp.x = X;
  temp.k = k;
  if (Hash[temp].flag) return Hash[temp].cnt;
  long long res = 0;
  int head = X / qwr[n - 1];
  for (int i = 0; i <= head - 1; i++) {
    if (i == 4 || i == 7)
      res += Get(qwr[n - 1] - 1, n - 1, k - 1);
    else
      res += Get(qwr[n - 1] - 1, n - 1, k);
  }
  if (head == 4 || head == 7)
    res += Get(X - head * qwr[n - 1], n - 1, k - 1);
  else
    res += Get(X - head * qwr[n - 1], n - 1, k);
  Hash[temp].flag = true;
  Hash[temp].cnt = res;
  return res;
}
void Init() {
  long long temp = X;
  MaxPos = 0;
  qwr[0] = 1;
  for (int i = 1; i <= 10; i++) qwr[i] = qwr[i - 1] * 10;
  while (temp != 0) MaxPos++, temp /= 10;
  for (int i = 0; i <= MaxPos; i++) {
    c[i] = Get(X, MaxPos, i);
    if (i == 0) c[0]--;
  }
}
long long Qwr(long long x, long long y) {
  long long ans = 1;
  while (y != 0) {
    if (y & 1LL) ans = (ans * x) % Pt;
    y /= 2;
    x = (x * x) % Pt;
  }
  return ans;
}
long long C(long long n, long long m) {
  long long fz = 1, fm = 1;
  for (int i = 0; i <= m - 1; i++) fz = (fz * (n - i)) % Pt;
  for (int i = 1; i <= m; i++) fm = (fm * (long long)i) % Pt;
  fm = Qwr(fm, Pt - 2);
  return fz * fm % Pt;
}
void Solve() {
  memset(f, 0, sizeof(f));
  for (int i = 0; i <= 6; i++) f[0][i][0] = C(c[0], i);
  for (int i = 1; i <= MaxPos; i++)
    for (int j = 0; j <= 6; j++)
      for (int k = 0; k <= min(MaxPos, j * i); k++) {
        for (int t = 0; t <= min(min(c[i], (long long)k / i), (long long)j);
             t++) {
          long long& res = f[i][j][k];
          res = (res + f[i - 1][j - t][k - i * t] * C(c[i], t) % Pt) % Pt;
        }
      }
  long long res = 0;
  for (int i = 1; i <= MaxPos; i++) {
    for (int j = 0; j <= i - 1; j++)
      res = (res + f[i - 1][6][j] * c[i] % Pt) % Pt;
  }
  for (int i = 1; i <= 6; i++) res = (res * (long long)i) % Pt;
  printf("%lld\n", res);
}
int main() {
  while (~scanf("%I64d", &X)) {
    Init();
    Solve();
  }
}