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;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long Mod = 1e9 + 7;
long long DP[15], nCr[15][15], dp[15];
void init() {
  DP[0] = 1;
  long long fac = 1;
  for (int i = 1; i < 15; i++) {
    fac *= 8;
    if (fac >= Mod) fac %= Mod;
    DP[i] = fac;
  }
  nCr[0][0] = 1;
  for (int i = 1; i < 15; i++) {
    for (int j = 0; j <= i; j++) {
      if (j)
        nCr[i][j] = nCr[i - 1][j] + nCr[i - 1][j - 1];
      else
        nCr[i][j] = 1;
    }
  }
}
long long power(int x) {
  if (x < 0)
    return 0ll;
  else
    return DP[x];
}
long long mult(long long a, long long b) {
  a *= b;
  if (a >= Mod) a %= Mod;
  return a;
}
long long NCR(long long a, long long b) {
  if (b > a || b < 0)
    return 0;
  else
    return nCr[a][b];
}
long long no_of_no(int no_of_digit, int no_of_lucky_digits) {
  if (no_of_lucky_digits > no_of_digit) return 0ll;
  if (no_of_digit == 0) return 1ll;
  long long ans = 0;
  ans = mult(
      mult(NCR(no_of_digit, no_of_lucky_digits), (1 << no_of_lucky_digits)),
      power(no_of_digit - no_of_lucky_digits));
  return ans;
}
int lucky_digits(string& s, int idx) {
  int cnt = 0;
  for (int i = 0; i <= idx; i++)
    if (s[i] == '4' || s[i] == '7') cnt++;
  return cnt;
}
long long something(long long x) {
  if (x < 6)
    return 0ll;
  else {
    long long ans = 1;
    for (long long i = 0; i < 6; i++) ans = (ans * (x - i)) % Mod;
    return ans;
  }
}
long long dp2[7][10][10];
long long inv(long long x, long long y) {
  if (y == 0)
    return 1ll;
  else {
    long long a = inv(x, y / 2);
    if (y & 1)
      return ((a * a) % Mod) * x % Mod;
    else
      return (a * a) % Mod;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  init();
  long long ans = 0, siz = (long long)(s).size();
  dp[lucky_digits(s, siz - 1)]++;
  for (int i = 0; i < siz; i++) {
    char d = s[i];
    for (char c = '0'; c < d; c++) {
      s[i] = c;
      for (int no = 0; no < 10; no++) {
        dp[no + lucky_digits(s, i)] += no_of_no(siz - i - 1, no);
      }
    }
    s[i] = d;
  }
  dp[0]--;
  if (dp[0] < 0) dp[0] = Mod - 1;
  for (int taken = 0; taken <= 9; taken++) dp2[0][taken][0] = 1;
  long long pro = 1;
  for (int no_of_people = 1; no_of_people <= 6; no_of_people++) {
    pro = (pro * (dp[0] + 1 - no_of_people)) % Mod;
    pro = (pro * inv(no_of_people, Mod - 2)) % Mod;
    dp2[no_of_people][0][0] = pro;
    for (int taken = 1; taken <= 9; taken++) {
      for (int sum = 0; sum <= 9; sum++) {
        long long del = 1;
        for (int tme = 0; tme <= no_of_people; tme++) {
          if (taken * tme > sum) break;
          dp2[no_of_people][taken][sum] +=
              del * dp2[no_of_people - tme][taken - 1][sum - tme * taken];
          if (dp2[no_of_people][taken][sum] >= Mod)
            dp2[no_of_people][taken][sum] %= Mod;
          del = (del * (dp[taken] - tme)) % Mod;
          del = (del * (inv(tme + 1, Mod - 2))) % Mod;
        }
      }
    }
  }
  for (int i = 9; i >= 1; i--) {
    for (int j = i - 1; j >= 0; j--) {
      ans = (ans + dp[i] * dp2[6][9][j]) % Mod;
    }
  }
  cout << (ans * 720) % Mod << endl;
  return 0;
}