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 long long int mod = 1000000007;
struct dxy {
  long long int d, x, y;
};
dxy mcde(long long int a, long long int b) {
  dxy r, t;
  if (b == 0) {
    r.d = a;
    r.x = 1;
    r.y = 0;
  } else {
    t = mcde(b, a % b);
    r.d = t.d;
    r.x = t.y;
    r.y = t.x - a / b * t.y;
  }
  return r;
}
long long int inv(long long int q) {
  dxy aux = mcde(q, mod);
  return ((aux.x % mod) + mod) % mod;
}
long long int C(long long int a, long long int b) {
  long long int res = 1;
  for (int i = (int)0; i < (int)(b); i++) {
    res = (res * a) % mod;
    a--;
  }
  for (int i = (int)0; i < (int)(b); i++) res = (res * inv(i + 1)) % mod;
  return res;
}
long long int ex(long long int base, long long int e) {
  if (e == 0) return 1;
  long long int aux = ex(base, e / 2);
  aux = (aux * aux) % mod;
  if (e % 2 == 1) aux = (aux * base) % mod;
  return aux;
}
vector<long long int> g(long long int m) {
  vector<long long int> res;
  for (int i = (int)0; i < (int)(10); i++) res.push_back(0);
  long long int pot = 1;
  while (m % pot == 0) pot *= 10;
  pot /= 10;
  for (int i = 0; i < 10 && i < log10(pot) + 1; i++)
    res[i] =
        (((C(log10(pot), i) * ex(2, i)) % mod) * ex(8, log10(pot) - i)) % mod;
  vector<long long int> aux = res;
  for (int i = (int)0; i < (int)(10); i++) res[i] = 0;
  for (int i = (int)0; i < (int)(m / pot); i++) {
    if (i == 4 || i == 7)
      for (int i = (int)0; i < (int)(9); i++)
        res[i + 1] = (res[i + 1] + aux[i]) % mod;
    else
      for (int i = (int)0; i < (int)(10); i++) res[i] = (res[i] + aux[i]) % mod;
  }
  return res;
}
vector<long long int> first(long long int m) {
  vector<long long int> res;
  for (int i = (int)0; i < (int)(10); i++) res.push_back(0);
  if (m == 0) return res;
  long long int pot = 1;
  while (m % pot == 0) pot *= 10;
  vector<long long int> aux = g(m % (pot));
  long long int n = m;
  n /= pot;
  int cont = 0;
  while (n > 0) {
    if (n % 10 == 4 || n % 10 == 7) cont++;
    n /= 10;
  }
  for (int i = (int)0; i < (int)(10 - cont); i++) res[i + cont] = aux[i];
  aux = first((m / pot) * pot);
  for (int i = (int)0; i < (int)(10); i++) res[i] += aux[i];
  return res;
}
vector<long long int> res;
long long int resp = 0;
int pos[7];
vector<long long int> auxres;
void rec(int n) {
  if (n == 7) {
    long long int aux = 1;
    auxres = res;
    for (int i = (int)0; i < (int)(7); i++) {
      aux = (aux * auxres[pos[i]]) % mod;
      auxres[pos[i]]--;
    }
    resp = (resp + aux) % mod;
  }
  if (n == 0) {
    for (int i = (int)0; i < (int)(10); i++) {
      pos[0] = i;
      rec(1);
    }
  }
  if (0 < n && n < 7) {
    int sum = pos[0];
    for (int i = (int)1; i < (int)(n); i++) sum -= pos[i];
    for (int i = (int)0; i < (int)(sum); i++) {
      pos[n] = i;
      rec(n + 1);
    }
  }
}
int main() {
  long long int m;
  cin >> m;
  m++;
  res = first(m);
  res[0]--;
  rec(0);
  cout << resp << endl;
  ;
}