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 = 1000000007;
long long dp[2][12], rs[12];
long long sum[12][12], all[12][12];
void init() {
  sum[0][0] = 1;
  for (int i = 1; i < 12; ++i) {
    for (int c = 0; c < i; ++c) {
      for (int k = (i == 1) ? 1 : 0; k < 10; ++k) {
        int tc = c;
        if (k == 4 || k == 7) ++tc;
        sum[i][tc] += sum[i - 1][c];
        sum[i][tc] %= mod;
      }
    }
  }
  for (int i = 0; i < 12; ++i) {
    all[0][i] = sum[0][i];
  }
  for (int c = 1; c < 12; ++c) {
    for (int k = 0; k < 12; ++k) {
      all[c][k] = all[c - 1][k] + sum[c][k];
      all[c][k] %= mod;
    }
  }
}
long long pow2(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long inv(long long n) { return pow2(n, mod - 2); }
inline void updata(long long& u, long long v) {
  v %= mod;
  u = (u + v) % mod;
}
void done(long long m) {
  char buf[1024];
  sprintf(buf, "%I64d", m);
  int len = strlen(buf);
  memset(dp, 0, sizeof(dp));
  int cur = 1, pre = 0;
  dp[0][0] = 1;
  int pcnt = 0;
  for (int k = 0; k < 12; ++k) {
    updata(rs[k], all[len - 1][k]);
  }
  for (int i = 0; i < len; ++i) {
    memset(dp[cur], 0, sizeof(dp[cur]));
    int remain = len - i - 1;
    for (int j = (i == 0) ? 1 : 0; j < buf[i] - '0'; ++j) {
      if (j == 4 || j == 7) {
        for (int k = 0; k <= remain; ++k) {
          updata(rs[k + 1 + pcnt], all[remain][k] % mod);
        }
      } else {
        for (int k = 0; k <= remain; ++k) {
          updata(rs[k + pcnt], all[remain][k] % mod);
        }
      }
    }
    if (buf[i] == '4' || buf[i] == '7') ++pcnt;
    swap(cur, pre);
  }
  --rs[0];
  ++rs[pcnt];
}
long long C(long long n, long long m) {
  long long res = 1;
  for (int i = 0; i < m; ++i) {
    res *= (n - i);
    res %= mod;
  }
  for (int i = 0; i < m; ++i) {
    res *= inv(i + 1);
    res %= mod;
  }
  return res;
}
long long dfs(int p, int c, int remain, long long all) {
  if (remain < 0) return 0;
  if (c <= 0) return 0;
  if (p == 11) {
    if (remain) return 0;
    return all;
  }
  long long result = 0;
  for (int k = 0; k <= remain; ++k) {
    if (k > rs[p]) continue;
    result += dfs(p + 1, c - k * p, remain - k, all * C(rs[p], k) % mod);
    result %= mod;
  }
  return result;
}
int main() {
  init();
  long long m;
  cin >> m;
  done(m);
  long long result = 0;
  for (int c = 1; c < 12; ++c) {
    if (!rs[c]) continue;
    result += rs[c] * (dfs(0, c, 6, 1) % mod) % mod;
    result %= mod;
  }
  result *= 720;
  result %= mod;
  cout << result << endl;
  return 0;
}