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;
vector<int> HI;
long long dp[20][20][2];
long long solve(int pos, int amnt, bool flag, int target, bool first) {
  if (pos == 0 && amnt == target) {
    return 1;
  }
  if (pos == 0) {
    return 0;
  }
  if (dp[pos][amnt][flag] != -1) return dp[pos][amnt][flag];
  long long ans = 0;
  for (int i = 0; i <= 9; i++) {
    if (first && i == 0) continue;
    if (amnt == target && (i == 4 || i == 7)) continue;
    if (!flag && i > HI[pos - 1]) {
      break;
    }
    long long cur = solve(pos - 1, amnt + (i == 4 || i == 7),
                          flag || HI[pos - 1] > i, target, false);
    ans += cur;
    ans %= 1000000007;
  }
  return dp[pos][amnt][flag] = ans;
}
long long R = 1000000007LL;
long long po(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      x %= R;
    }
    y = (y * y);
    y %= R;
    b /= 2;
  }
  return x;
}
long long comb(long long m, long long k) {
  long long diff = m - k;
  long long sol = 1;
  while (m > diff) {
    sol *= m % R;
    sol %= R;
    m--;
  }
  return sol;
}
long long choose_six(long long amnt) {
  long long a = comb(amnt, 6);
  long long b = po(6, R - 2);
  return (a * b) % R;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int aux = n;
  while (n > 0) {
    HI.push_back(n % 10);
    n /= 10;
  }
  long long ways[20];
  for (int i = 0; i <= HI.size(); i++) {
    ways[i] = 0;
    for (int j = HI.size(); j >= 1; j--) {
      memset(dp, -1, sizeof dp);
      long long cur = solve(j, 0, (j < HI.size()), i, true);
      ways[i] += cur;
      ways[i] %= 1000000007;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= HI.size(); i++) {
    long long cur = 1;
    for (int a = 0; a < i; a++) {
      long long A = ways[a];
      ways[a]--;
      for (int b = 0; a + b < i; b++) {
        long long B = A * ways[b];
        B %= 1000000007;
        ways[b]--;
        for (int c = 0; a + b + c < i; c++) {
          long long C = B * ways[c];
          C %= 1000000007;
          ways[c]--;
          for (int d = 0; a + b + c + d < i; d++) {
            long long D = C * ways[d];
            D %= 1000000007;
            ways[d]--;
            for (int e = 0; a + b + c + d + e < i; e++) {
              long long E = D * ways[e];
              E %= 1000000007;
              ways[e]--;
              for (int f = 0; a + b + c + d + e + f < i; f++) {
                long long F = E * ways[f];
                F %= 1000000007;
                ans += ways[i] * F;
                ans %= 1000000007;
              }
              ways[e]++;
            }
            ways[d]++;
          }
          ways[c]++;
        }
        ways[b]++;
      }
      ways[a]++;
    }
  }
  cout << ans << endl;
  return 0;
}