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 <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
inline T Dist(T x1, T y1, T x2, T y2) {
  return sqrt((x1 - x2 * x1 - x2) + (y1 - y2 * y1 - y2));
}
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
long long Bigmod(long long base, long long power, long long MOD) {
  long long ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
long long ModInverse(long long number, long long MOD) {
  return Bigmod(number, MOD - 2, MOD);
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int Reset(int N, int pos) { return N = N & ~(1 << pos); }
bool Chkbit(int N, int pos) { return (bool)(N & (1 << pos)); }
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
long long int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int dp[12][12][2];
string s;
int n, L;
int SOlve(int pos, int len, int ch) {
  if (pos == n) return (len == L);
  int &res = dp[pos][len][ch];
  if (res != -1) return res;
  res = 0;
  int l = (int)(s[pos] - '0');
  if (ch) l = 9;
  for (int i = 0; i <= l; i++) {
    res += SOlve(pos + 1, len + (i == 4 || i == 7), ch | (i < (s[pos] - '0')));
  }
  return res;
}
long long int Dp[100], dpp[11][11][11], F[11];
long long int DP(int pos, int baki, int koto) {
  if (baki == 0) return 1;
  if (pos == -1) return 0;
  long long int &res = dpp[pos][baki][koto];
  if (res != -1) return res;
  res = 0;
  for (int i = 0; i <= min(Dp[pos], (long long int)baki); i++) {
    long long int tp = 1, Dw = 1;
    if (i * pos > koto) break;
    for (int j = 0; j < i; j++)
      tp = (tp * (Dp[pos] - j)) % 1000000007, Dw = (Dw * (j + 1)) % 1000000007;
    tp = (tp * ModInverse(Dw, 1000000007)) % 1000000007;
    res = (res + DP(pos - 1, baki - i, koto - (i * pos)) * (tp)) % 1000000007;
  }
  return res;
}
int main() {
  F[0] = 1;
  for (int i = 1; i <= 10; i++) {
    F[i] = (F[i - 1] * i) % 1000000007;
  }
  cin >> s;
  n = s.size();
  int Id = 0;
  for (int i = 0; i <= 10; i++) {
    memset(dp, -1, sizeof(dp));
    L = i;
    Dp[i] = SOlve(0, 0, 0);
    if (Dp[i]) Id = i;
  }
  Dp[0]--;
  long long int ans = 0;
  for (int i = Id; i >= 1; i--) {
    memset(dpp, -1, sizeof(dpp));
    ans = (ans + ((DP(i - 1, 6, i - 1) * Dp[i])) % 1000000007) % 1000000007;
  }
  cout << (ans * F[6]) % 1000000007 << endl;
  return 0;
}