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 double EPS = 1e-8;
string to_s(int n) {
  string s = "";
  while (n) {
    s += (n % 10) + '0';
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
int dp[3][11][11];
void count_le(int in, int d) {
  int l = (4 < d) + (7 < d);
  int ll = d - l - (in == 1);
  for (int i = 0; i <= 10; i++) {
    dp[0][in][i] += dp[0][in - 1][i] * 8 + dp[1][in - 1][i] * ll;
    dp[0][in][i + 1] = dp[0][in - 1][i] * 2 + dp[1][in - 1][i] * l;
  }
}
void count_eq(int in, int d) {
  int m = 0;
  for (int i = 1; i <= 9; i++) {
    if (dp[1][in - 1][i]) m = i;
  }
  dp[1][in][m + ((d == 4) || (d == 7))]++;
}
void count_mo(int in, int d) {
  int l = (4 > d) + (7 > d);
  int ll = 9 - d - l;
  for (int i = 0; i <= 9; i++) {
    dp[2][in][i] += dp[2][in - 1][i] * 8 + dp[1][in - 1][i] * ll;
    dp[2][in][i + 1] = dp[2][in - 1][i] * 2 + dp[1][in - 1][i] * l;
  }
}
int co[11];
void cal(int n) {
  string s = to_s(n);
  dp[1][0][0] = 1;
  for (int i = 1; i <= (int)(s.size()); i++) {
    count_le(i, s[i - 1] - '0');
    count_eq(i, s[i - 1] - '0');
    count_mo(i, s[i - 1] - '0');
  }
  for (int i = 1; i <= (int)(s.size()); i++) {
    for (int j = 0; j <= 9; j++) {
      co[j] += dp[0][i][j] + dp[1][i][j];
      if (i < (int)(s.size())) co[j] += dp[2][i][j];
    }
  }
}
const int mod = 1000000007;
long long int fac(int n, int r) {
  unsigned long long int m = 1;
  for (int i = r + 1; i <= n; i++) {
    m *= i;
    m %= mod;
  }
  return m;
}
long long int M, ma;
void Comb(int in, vector<int> v, int count) {
  if (count == 6) {
    long long int m = 0, l = 1;
    for (int i = 0; i < 10; i++) {
      m += i * v[i];
      if (v[i] > co[i]) m = 1000;
    }
    if (m >= ma) return;
    m = 1;
    for (int i = 0; i < 10; i++) {
      if (v[i]) {
        long long int mm = fac(co[i], co[i] - v[i]);
        l *= fac(v[i], 0);
        m *= mm;
        m %= mod;
      }
    }
    m *= 720 / l;
    m %= mod;
    M += (m * co[ma]) % mod;
    M %= mod;
    return;
  }
  for (int i = in; i >= 0; i--) {
    v[i]++;
    Comb(i, v, count + 1);
    v[i]--;
  }
}
int main() {
  long long int n, m = 0;
  cin >> n;
  cal(n);
  for (int i = 1; i < 10; i++) {
    if (co[i]) {
      M = 0, ma = i;
      Comb(i - 1, vector<int>(10, 0), 0);
      m += M;
      m %= mod;
    }
  }
  cout << m << endl;
  return 0;
}