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 int MOD = 1000000007;
int lenMax;
int p[20];
long long cnt[20];
long long C(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  if (k == n) return 1;
  long long ans = 1;
  for (int i = n; i > n - k; i--) ans *= i;
  for (int i = k; i > 0; i--) ans /= i;
  return ans % MOD;
}
int eightPow(int p) {
  int k = 1;
  for (int i = 0; i < p; i++) k *= 8;
  return k % MOD;
}
long long decGreaters(int pos, int lucks) {
  if (pos >= lenMax) return 0;
  long long ans = 0, twopow = 1;
  for (int i = 0; i < lucks; i++) twopow *= 2;
  for (int k = p[pos] + 1; k <= 9; k++)
    if (k == 4 || k == 7) {
      ans += ((twopow / 2) * C(lenMax - pos - 1, lucks - 1) *
              eightPow(lenMax - pos - lucks)) %
             MOD;
      ans %= MOD;
    } else {
      ans += (twopow * C(lenMax - pos - 1, lucks) *
              eightPow(lenMax - pos - lucks - 1)) %
             MOD;
      ans %= MOD;
    }
  if (p[pos] == 7 || p[pos] == 4)
    return (ans + decGreaters(pos + 1, lucks - 1)) % MOD;
  else
    return (ans + decGreaters(pos + 1, lucks)) % MOD;
}
int getLen(int k) {
  int l = 0;
  while (k) {
    l++;
    k /= 10;
  }
  return l;
}
long long cntWays(int k, int lucks) {
  if (k >= 6)
    if (lucks >= 0)
      return 1;
    else
      return 0;
  long long ans = 0, tmp = 0;
  for (int i = 0; i <= lucks; i++) {
    if (cnt[i] > 0) {
      cnt[i]--;
      ans += ((cnt[i] + 1) * cntWays(k + 1, lucks - i)) % MOD;
      cnt[i]++;
      ans %= MOD;
    }
  }
  return ans % MOD;
}
int main() {
  int m;
  cin >> m;
  lenMax = getLen(m);
  int cpy = m, l = 0;
  while (cpy) {
    l++;
    p[lenMax - l] = cpy % 10;
    cpy /= 10;
  }
  int k = 1;
  for (int i = 0; i <= lenMax; i++) {
    cnt[i] = k * C(lenMax, i) * eightPow(lenMax - i) - decGreaters(0, i);
    cnt[i] %= MOD;
    if (i == 0) cnt[0]--;
    while (cnt[i] < 0) cnt[i] += MOD;
    k *= 2;
  }
  long long ans = 0;
  for (int i = 1; i <= lenMax; i++) {
    cnt[i]--;
    ans = (ans + ((cnt[i] + 1) * cntWays(0, i - 1)) % MOD) % MOD;
    cnt[i]++;
  }
  cout << ans % MOD << endl;
}