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 long long MOD = 1e9 + 7;
int n;
vector<int> dig;
long long cnt[15];
long long C[25][25];
struct cond {
  int sum;
  int a[20];
  string s;
  cond() {
    for (int i = 0; i < 20; i++) {
      a[i] = 0;
    }
    s = "";
    sum = 0;
  }
};
void calculateC() {
  for (int i = 0; i <= 20; i++)
    for (int j = 0; j <= 20; j++) C[i][j] = 0;
  for (int i = 0; i < 20; i++) C[i][0] = 1;
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= 20; j++)
      C[i][j] =
          ((C[i][j] % MOD) + ((C[i - 1][j] + C[i - 1][j - 1]) % MOD)) % MOD;
}
long long C2(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  long long ans = 1;
  for (int i = n; i > n - k; i--) ans = (ans * i) % MOD;
  return ans % MOD;
}
long long Power2(int n) {
  long long k = 1ll;
  for (int i = 1; i <= n; i++) k = (k * 2ll) % MOD;
  return k;
}
long long Power8(int n) {
  long long k = 1ll;
  for (int i = 1; i <= n; i++) k = (k * 8ll) % MOD;
  return k;
}
bool good(int n) {
  if (n == 4 || n == 7) return true;
  return false;
}
void findcnt(int pos, int sum) {
  if (pos == (int)dig.size()) return;
  int p = (int)dig.size() - pos;
  long long Q = (long long)dig[pos];
  if (p == 1) {
    cnt[0]--;
    for (int i = 0; i <= Q; i++)
      if (good(i))
        cnt[sum + 1]++;
      else
        cnt[sum]++;
    return;
  }
  for (int i = 0; i <= p - 1; i++) {
    for (int j = 0; j < Q; j++) {
      if (!good(j))
        cnt[i + sum] += Power2(i) * C[p - 1][i] * Power8(p - 1 - i);
      else
        cnt[i + sum + 1] += Power2(i) * C[p - 1][i] * Power8(p - 1 - i);
    }
  }
  if (good(dig[pos]))
    findcnt(pos + 1, sum + 1);
  else
    findcnt(pos + 1, sum);
}
long long ans = 0;
vector<cond> allposib;
void BT(int pos, int sum, string s) {
  if (pos == 6) {
    cond A;
    for (int i = 0; i < (int)s.length(); i++) A.a[(int)s[i] - (int)'0']++;
    A.sum = sum;
    A.s = s;
    if (sum <= 10) allposib.push_back(A);
  } else
    for (int i = 0; i <= 10; i++)
      BT(pos + 1, sum + i, s + (char)(i + (int)'0'));
}
int fac(int n) {
  int ans = 1;
  for (int i = 1; i <= n; i++) ans *= i;
  return ans;
}
int main() {
  calculateC();
  for (int i = 0; i <= 10; i++) cnt[i] = 0;
  cin >> n;
  while (n) {
    dig.push_back(n % 10);
    n /= 10;
  }
  reverse((dig).begin(), (dig).end());
  findcnt(0, 0);
  BT(0, 0, "");
  long long ans = 0;
  for (int i = 0; i < (int)allposib.size(); i++) {
    int from = allposib[i].sum + 1;
    long long tmp = 1, posfor7 = 0;
    for (int j = 0; j <= 10; j++) {
      tmp = (tmp * (C2(cnt[j], allposib[i].a[j]))) % MOD;
    }
    for (int j = from; j <= 10; j++) posfor7 += cnt[j];
    posfor7 %= MOD;
    tmp = (tmp * posfor7) % MOD;
    ans = (ans + tmp) % MOD;
  }
  cout << ans % MOD << endl;
  return 0;
}