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 = 21;
const long long MOD = 1000000007;
int n;
long long m;
long long C[MAXN][MAXN];
long long g[MAXN], s[MAXN], ten[MAXN], eight[MAXN];
inline void update(long long& x, long long y) { y %= MOD, x += y, x %= MOD; }
inline long long P(const long long& x, int y) {
  if (x < y) return 0;
  long long res = 1;
  for (long long i = x; i >= x - y + 1; --i) res = (res * i) % MOD;
  return res;
}
inline pair<int, int> get(long long num, int x) {
  int res4 = 0, res7 = 0;
  for (int i = 1; i <= x; ++i) num /= 10;
  for (long long i = num; i > 0; i /= 10)
    if (i % 10 == 4)
      res4++;
    else if (i % 10 == 7)
      res7++;
  return pair<int, int>(res4, res7);
}
inline long long F(const long long& num, int x, int a, int b) {
  pair<int, int> p = get(num, x);
  a -= p.first, b -= p.second;
  if (a < 0 || b < 0 || a + b > x) return 0;
  return (((C[x][a] * C[x - a][b]) % MOD) * eight[x - a - b]) % MOD;
}
inline long long G(long long num, int x, int a, int b) {
  long long res = 0;
  for (; num + ten[x] <= m; num += ten[x]) update(res, F(num, x, a, b));
  if (x > 0) {
    if (num <= m) update(res, G(num, x - 1, a, b));
  } else
    update(res, F(num, x, a, b));
  return res;
}
inline void preProcess() {
  ten[0] = eight[0] = 1;
  for (int i = 1; i < MAXN; ++i)
    ten[i] = ten[i - 1] * 10, eight[i] = eight[i - 1] * 8;
  while (ten[n] <= m) n++;
  C[0][0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j) update(g[i], G(0, n - 1, j, i - j));
  g[0]--;
}
inline long long dp(int s, int x, int y, int z) {
  if (y < 0 || z < 0) return 0;
  if (x == s) return (y == 0) ? 1 : 0;
  long long res = 0;
  for (int i = 0; i <= y; ++i) {
    long long k = (C[y][i] * P(g[x], i)) % MOD;
    update(res, k * dp(s, x + 1, y - i, z - i * x));
  }
  return res;
}
int main() {
  scanf("%I64d\n", &m);
  preProcess();
  long long res = 0;
  for (int s = 1; s <= n; ++s) update(res, g[s] * dp(s, 0, 6, s - 1));
  printf("%I64d\n", res);
  fclose(stdin);
  fclose(stdout);
  return 0;
}