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>
#pragma comment(linker, "/STACK:1073741824")
using namespace std;
const long long mod = 1000000007;
vector<int> have(10);
vector<int> operator+(vector<int> a, vector<int> b) {
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) a[i] += b[i];
  return a;
}
vector<int> operator*(vector<int> a, int b) {
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) a[i] *= b;
  return a;
}
vector<int> operator<<(vector<int> a, int b) {
  for (int(i) = ((int((a).size()))); (i)--;)
    if (i + b < (int((a).size()))) a[i + b] = a[i];
  for (int(i) = 0; (i) < (b); ++(i)) a[i] = 0;
  return a;
}
vector<int> full[10];
void print(const vector<int>& a) {
  printf("##\n");
  for (int(i) = 0; (i) < (int((a).size())); ++(i)) printf("%d: %d\n", i, a[i]);
  printf("##\n");
}
vector<int> calc(string nmax) {
  vector<int> res(10);
  int c = nmax[0] - '0';
  if (nmax.size() == 1) {
    res[0] = c + 1;
    if (c >= 7) {
      ++res[1];
      --res[0];
    }
    if (c >= 4) {
      ++res[1];
      --res[0];
    }
  } else {
    vector<int> right_ = calc(nmax.substr(1));
    if (c == 4 || c == 7) right_ = right_ << 1;
    res = res + right_;
    for (int(i) = (0); (i) <= (c - 1); ++(i)) {
      if (i == 4 || i == 7) {
        res = res + (full[nmax.size() - 1] << 1);
      } else {
        res = res + full[nmax.size() - 1];
      }
    }
  }
  return res;
}
long long binpow(long long x, long long n) {
  long long a = 1;
  while (n) {
    if (n & 1) a = a * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return a;
}
long long ans = 0;
void rec(int v, int I, long long ways, int parties, int k = 1) {
  if (I == -1) {
    if (parties != 0) return;
    ans += ways;
    if (ans >= mod) ans -= mod;
    return;
  }
  if (v > I && have[I] && parties) {
    --have[I];
    rec(v - I, I,
        ways * parties % mod * binpow(k, mod - 2) % mod * (have[I] + 1LL) % mod,
        parties - 1, k + 1);
    ++have[I];
  }
  rec(v, I - 1, ways, parties);
}
int main() {
  int n;
  scanf("%d", &n);
  char s[11];
  sprintf(s, "%d", n);
  full[0].assign(10, 0);
  for (int(i) = (1); (i) <= (9); ++(i)) {
    full[i] = calc(string(i, '9'));
  }
  have = calc(string(s));
  --have[0];
  for (int(i) = (1); (i) <= (9); ++(i))
    if (have[i]) {
      --have[i];
      rec(i, 9, have[i] + 1LL, 6);
      ++have[i];
    }
  cout << ans % mod << endl;
  return 0;
}