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 double pi = acos(-1.0);
const double eps = 1e-8;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int m, now;
long long a[12], n[12], pw[12];
int f[12][12];
long long mod = 1000000007;
long long dfs(int i, int s, bool e) {
  if (i == -1) return (s == now);
  if (!e && f[i][s] != -1) return f[i][s];
  long long res = 0;
  int u = e ? n[i] : 9;
  for (int d = 0; d <= u; ++d)
    res += dfs(i - 1, s + (d == 4 || d == 7), e && d == u);
  return e ? res : f[i][s] = res;
}
long long solve(long long x) {
  int l = 0;
  for (; x; x /= 10) n[l++] = x % 10;
  return dfs(l - 1, 0, 1);
}
long long tans;
long long pow(long long a, long long k) {
  if (k == 0) return 1;
  if (k == 1) return a;
  long long tmp = pow(a, k / 2);
  tmp = (tmp * tmp) % mod;
  if (k & 1)
    return (tmp * a) % mod;
  else
    return tmp;
}
long long get2(long long a, long long b) {
  long long ret1 = 1, ret2 = 1;
  for (int i = 1; i <= b; ++i) {
    ret1 = (ret1 * (a - i + 1)) % mod;
    ret2 = (ret2 * i);
  }
  ret1 = (ret1 * (pow(ret2, mod - 2))) % mod;
  return ret1;
}
void get(int deep, int left1, int left2, long long tmp) {
  if (deep == 10) {
    if (!left2) tans = (tans + tmp) % mod;
    return;
  }
  long long t = tmp;
  for (int i = 0; i <= min(a[deep], (long long)left2) && i * deep <= left1; ++i)
    get(deep + 1, left1 - i * deep, left2 - i, (t * get2(a[deep], i)) % mod);
}
long long work(int k) {
  tans = 0;
  get(0, k - 1, 6, a[k]);
  return tans % mod;
}
int main() {
  while (scanf("%d", &m) == 1) {
    pw[0] = 1;
    for (int i = 1; i <= 10; ++i) pw[i] = (pw[i - 1] * i) % mod;
    for (now = 0; now < 10; ++now) {
      memset(f, -1, sizeof(f));
      a[now] = solve(m);
    }
    a[0]--;
    long long ans = 0;
    for (int i = 1; i < 10; ++i) ans = (ans + work(i)) % mod;
    ans = (ans * 720) % mod;
    cout << ans << endl;
  }
  return 0;
}