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 memo[12][12];
long long memo1[12][12];
long long freq[12];
long long comb[20][20];
int N;
string s;
void pre() {
  for (int i = 1; i <= 19; ++i)
    for (int j = 0; j <= i; ++j) {
      if (j == 0 || j == i)
        comb[i][j] = 1;
      else
        comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % 1000000007;
    }
}
long long modinv(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  long long v = modinv(a, (n / 2));
  if (n % 2) return (((v * v) % 1000000007) * a) % 1000000007;
  return (v * v) % 1000000007;
}
long long nck(long long n, long long k) {
  long long res = 1;
  for (long long i = n; i >= n - k + 1; --i) {
    res *= i;
    res %= 1000000007;
  }
  long long prod = 1;
  for (int i = 1; i <= k; ++i) {
    prod *= i;
    prod %= 1000000007;
  }
  long long inv = modinv(prod, 1000000007 - 2);
  return (res * inv) % 1000000007;
}
long long dp1(long long idx, long long rem) {
  if (rem < 0) return 0;
  if (memo1[idx][rem] != -1) return memo1[idx][rem];
  memo1[idx][rem] = 0;
  if (idx >= N && rem == 0) {
    memo1[idx][rem] = 1;
    return memo1[idx][rem];
  } else if (idx >= N) {
    memo1[idx][rem] = 0;
    return memo1[idx][rem];
  }
  for (int i = 0; i <= 9; ++i) {
    if (i != 4 && i != 7)
      memo1[idx][rem] = (memo1[idx][rem] + dp1(idx + 1, rem)) % 1000000007;
    else
      memo1[idx][rem] = (memo1[idx][rem] + dp1(idx + 1, rem - 1)) % 1000000007;
  }
  return memo1[idx][rem];
}
long long dp(long long idx, long long rem) {
  if (rem < 0) return 0;
  if (memo[idx][rem] != -1) return memo[idx][rem];
  memo[idx][rem] = 0;
  if (idx >= N && rem == 0) {
    memo[idx][rem] = 1;
    return memo[idx][rem];
  } else if (idx >= N) {
    memo[idx][rem] = 0;
    return memo[idx][rem];
  } else {
    for (int i = 0; i < s[idx] - 48; ++i) {
      if (i != 4 && i != 7)
        memo[idx][rem] = (memo[idx][rem] + dp1(idx + 1, rem)) % 1000000007;
      else
        memo[idx][rem] = (memo[idx][rem] + dp1(idx + 1, rem - 1)) % 1000000007;
    }
    if ((s[idx] - 48) == 4 || (s[idx] - 48) == 7)
      memo[idx][rem] = (memo[idx][rem] + dp(idx + 1, rem - 1));
    else
      memo[idx][rem] = (memo[idx][rem] + dp(idx + 1, rem));
  }
  return memo[idx][rem];
}
int main() {
  pre();
  cin >> s;
  N = s.size();
  memset(memo, -1, sizeof(memo));
  memset(memo1, -1, sizeof(memo1));
  freq[0] = dp(0, 0) - 1;
  for (int i = 1; i <= 10; ++i) {
    freq[i] = dp(0, i);
  }
  long long sum = 0;
  for (int g = 0; g <= 9; ++g) {
    if (freq[g]) {
      for (int a = 0; a <= 9; ++a) {
        for (int b = 0; b <= 9; ++b)
          for (int c = 0; c <= 9; ++c)
            for (int d = 0; d <= 9; ++d)
              for (int e = 0; e <= 9; ++e)
                for (int f = 0; f <= 9; ++f) {
                  if (a + b + c + d + e + f < g && freq[g]) {
                    int cnt[10];
                    memset(cnt, 0, sizeof(cnt));
                    long long ans = a + b + c + d + e + f;
                    long long prod = 1;
                    prod *= freq[a];
                    prod %= 1000000007;
                    cnt[a]++;
                    prod *= (freq[b] - cnt[b]);
                    prod %= 1000000007;
                    cnt[b]++;
                    prod *= (freq[c] - cnt[c]);
                    prod %= 1000000007;
                    cnt[c]++;
                    prod *= (freq[d] - cnt[d]);
                    prod %= 1000000007;
                    cnt[d]++;
                    prod *= (freq[e] - cnt[e]);
                    prod %= 1000000007;
                    cnt[e]++;
                    prod *= (freq[f] - cnt[f]);
                    prod %= 1000000007;
                    cnt[f]++;
                    prod *= freq[g];
                    prod %= 1000000007;
                    sum += prod;
                    sum %= 1000000007;
                  }
                }
      }
    }
  }
  cout << sum << endl;
  return 0;
}