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-9;
pair<int, int> operator+(const pair<int, int>& p1, const pair<int, int>& p2) {
  return pair<int, int>(p1.first + p2.first, p1.second + p2.second);
}
pair<int, int> operator-(const pair<int, int>& p1, const pair<int, int>& p2) {
  return pair<int, int>(p1.first - p2.first, p1.second - p2.second);
}
int operator*(const pair<int, int>& p1, const pair<int, int>& p2) {
  return (p1.first * p2.first + p1.second * p2.second);
}
int operator^(const pair<int, int>& p1, const pair<int, int>& p2) {
  return (p1.first * p2.second - p1.second * p2.first);
}
long long lucky[20];
long long po(long long a, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) {
      res = res * a % 1000000007;
    }
    a = a * a % 1000000007;
    k >>= 1;
  }
  return res;
}
long long inv[20];
long long C(long long n, long long k) {
  long long res = 1;
  for (long long i = 0; i < k; i++) {
    res = res * (n - i) % 1000000007 * inv[i + 1] % 1000000007;
  }
  return res;
}
void go(long long now, long long len, long long flag, char* m, long long tot,
        long long ways) {
  if (now == len) {
    lucky[tot] = lucky[tot] + ways;
    return;
  }
  long long num = 0;
  long long no = 0;
  long long tail = flag ? 9 : m[now] - '0';
  for (long long i = 0; i < tail; i++) {
    if (i == 4 || i == 7)
      num++;
    else
      no++;
  }
  go(now + 1, len, 1, m, tot + 1, ways * num);
  go(now + 1, len, 1, m, tot, ways * no);
  if (tail == 4 || tail == 7) {
    go(now + 1, len, flag, m, tot + 1, ways);
  } else
    go(now + 1, len, flag, m, tot, ways);
}
long long ans = 0;
long long chosen[20];
void dfs(long long now, long long rem, long long tot) {
  if (now == 0) {
    chosen[0] = 6 - tot;
    if (6 - tot > lucky[0]) return;
    long long res = 1;
    for (long long i = 0; i <= 10; i++) {
      res = res * C(lucky[i], chosen[i]) % 1000000007;
    }
    res = res * (long long)720 % 1000000007;
    ans = (ans + res) % 1000000007;
    return;
  }
  for (long long i = 0; i <= lucky[now] && i * now <= rem && tot + i <= 6;
       i++) {
    chosen[now] = i;
    dfs(now - 1, rem - i * now, tot + i);
  }
}
signed main() {
  for (long long i = 1; i <= 11; i++) {
    inv[i] = po(i, 1000000007 - 2);
  }
  char m[100];
  cin >> m;
  go(0, strlen(m), 0, m, 0, 1);
  lucky[0]--;
  for (long long i = 1; i <= 10; i++) {
    if (lucky[i]) {
      memset(chosen, 0, sizeof(chosen));
      ;
      chosen[i] = 1;
      dfs(i - 1, i - 1, 0);
    }
  }
  cout << ans;
  return 0;
}