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;
long long Set(long long N, long long pos) { return N = N | (1 << pos); }
long long reset(long long N, long long pos) { return N = N & ~(1 << pos); }
bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); }
void CI(long long &_x) { scanf("%d", &_x); }
void CO(long long &_x) { cout << _x; }
template <typename T>
void getarray(T a[], long long n) {
  for (long long i = 0; i < n; i++) cin >> a[i];
}
template <typename T>
void prLLIarray(T a[], long long n) {
  for (long long i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a[n - 1] << endl;
}
const double EPS = 1e-9;
const long long INF = 0x7f7f7f7f;
long long dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};
long long dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};
long long dr4[4] = {0, 0, 1, -1};
long long dc4[4] = {-1, 1, 0, 0};
long long kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};
long long kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};
long long cnt[15];
vector<long long> V;
long long dp[15][15][3];
long long rec(long long pos, long long rem, long long last) {
  if (rem < 0) return 0;
  if (pos == V.size()) {
    if (rem == 0) return 1;
    return 0;
  }
  long long &ans = dp[pos][rem][last];
  if (ans != -1) return ans;
  ans = 0;
  for (long long i = 0; i <= 9; i++) {
    long long rr = rem;
    if (i == 4 || i == 7) rr--;
    if (last == 1) {
      if (V[pos] == i)
        ans += rec(pos + 1, rr, last);
      else if (V[pos] > i)
        ans += rec(pos + 1, rr, 0);
    } else if (last == 0) {
      ans += rec(pos + 1, rr, 0);
    }
    ans = ans % 1000000007;
  }
  return ans;
}
void process(long long num) {
  V.clear();
  while (num) {
    V.push_back(num % 10);
    num = num / 10;
  }
  reverse(V.begin(), V.end());
}
long long go(long long pos, long long rem) {
  if (rem < 0) return 0;
  if (pos == 6) return 1;
  long long ans = 0;
  for (long long i = 0; i <= rem; i++)
    if (cnt[i] >= 1) {
      cnt[i]--;
      ans += (cnt[i] + 1) * go(pos + 1, rem - i);
      ans %= 1000000007;
      cnt[i]++;
    }
  return ans;
}
int main() {
  memset(dp, -1, sizeof dp);
  long long n;
  cin >> n;
  process(n);
  for (long long i = 0; i <= 10; i++) {
    cnt[i] = rec(0, i, 1);
  }
  cnt[0]--;
  long long ans = 0;
  for (long long i = 0; i <= 10; i++) {
    ans += cnt[i] * go(0, i - 1);
    ans %= 1000000007;
  }
  cout << ans << "\n";
}