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;
void SR(int &x) { scanf("%d", &x); }
void SR(long long &x) { scanf("%lld", &x); }
void SR(double &x) { scanf("%lf", &x); }
void SR(char *s) { scanf("%s", s); }
void RI() {}
template <typename I, typename... T>
void RI(I &x, T &...tail) {
  SR(x);
  RI(tail...);
}
const int MOD = 1e9 + 7;
int n;
void read() { RI(n); }
int dig[15], len;
int dp[15][2][15];
void calc(int pos, bool any) {
  int *my = dp[pos][any];
  if (pos == 0) {
    for (int i = 0; i < int(10); i++) {
      bool ok = 1;
      if (!any && i > dig[pos]) ok = 0;
      if (ok) my[i == 4 || i == 7]++;
    }
    return;
  }
  for (int i = 0; i < int(10); i++) {
    bool ok = 1;
    if (!any && i > dig[pos]) ok = 0;
    if (ok) {
      bool luc = (i == 4 || i == 7);
      int *sub = dp[pos - 1][any || i < dig[pos]];
      for (int j = 0; j < int(15 - luc); j++) my[j + luc] += sub[j];
    }
  }
}
void build() {
  for (len = 0; n > 0; n /= 10) dig[len++] = n % 10;
  for (int i = 0; i < int(len); i++)
    for (int j = 0; j < int(2); j++)
      if (i + j < len) calc(i, j);
}
int *has;
int sum[15];
int inv(int x) {
  return x == 1 ? 1LL : 1LL * inv(MOD % x) * (MOD - MOD / x) % MOD;
}
int C(int x, int y) {
  long long ans = 1;
  for (int i = 0; i < int(y); i++) ans = ans * (x - i) % MOD;
  for (int i = (1); i <= int(y); i++) ans = ans * inv(i) % MOD;
  return ans;
}
void dfs(int pos, int rst, int cur, int way) {
  if (pos == 15 || cur >= 13) return;
  if (rst == 0) {
    sum[cur] = (sum[cur] + way) % MOD;
    return;
  }
  for (int i = (0); i <= int(min(rst, has[pos])); i++)
    dfs(pos + 1, rst - i, cur + i * pos, 1LL * way * C(has[pos], i) % MOD);
}
void sol() {
  has = dp[len - 1][0];
  has[0]--;
  dfs(0, 6, 0, 1);
  long long ans = 0, prv = 0;
  for (int i = 0; i < int(15); i++) {
    ans = (ans + 1LL * has[i] * prv) % MOD;
    prv = (prv + sum[i]) % MOD;
  }
  ans = ans * 720 % MOD;
  printf("%lld\n", (ans + MOD) % MOD);
}
int main() {
  read();
  build();
  sol();
  return 0;
}