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>
inline T BM(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T MDINV(T a, T M) {
  return BM(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
string h;
long long int b;
long long int vis[13][2][13];
long long int dp(long long int i, long long int choto, long long int ld) {
  if (i == h.size()) {
    if (ld == b)
      return 1;
    else
      return 0;
  }
  long long int &ret = vis[i][choto][ld];
  if (ret != -1) return ret;
  ret = 0;
  if (!choto) {
    long long int ab = h[i] - '0';
    for (long long int j = 0; j <= ab; j++) {
      if (j == ab) {
        if (j == 4 || j == 7)
          ret += dp(i + 1, choto, ld + 1);
        else
          ret += dp(i + 1, choto, ld);
      } else {
        if (j == 4 || j == 7)
          ret += dp(i + 1, 1, ld + 1);
        else
          ret += dp(i + 1, 1, ld);
      }
    }
  } else {
    for (long long int j = 0; j <= 9; j++) {
      if (j == 4 || j == 7)
        ret += dp(i + 1, 1, ld + 1);
      else
        ret += dp(i + 1, 1, ld);
    }
  }
  return ret;
}
long long int fact(long long int num1, long long int num2) {
  if (num1 < num2) return 0;
  if (num1 == num2)
    return 1;
  else {
    long long int sum = num1 - num2;
    long long int res = 1;
    for (long long int i = sum + 1; i <= num1; i++) {
      res = (res * i) % 1000000007LL;
    }
    for (long long int i = 1; i <= num2; i++) {
      res = (res * MDINV(i, 1000000007LL)) % 1000000007LL;
    }
    return res;
  }
}
long long int digi[12];
long long int vi[12][100][7];
long long int dp1(long long int i, long long int ld, long long int nu) {
  if (i == b) {
    if (nu == 6 && ld < b)
      return 720;
    else
      return 0;
  }
  if (nu == 6) {
    if (ld < b)
      return 720;
    else
      return 0;
  }
  long long int &ret = vi[i][ld][nu];
  if (ret != -1) return ret;
  ret = 0;
  for (long long int j = 1; j <= min(6 - nu, digi[i]); j++) {
    ret = (ret + fact(digi[i], j) * dp1(i + 1, j * i + ld, nu + j)) %
          1000000007LL;
  }
  ret = (ret + dp1(i + 1, ld, nu)) % 1000000007LL;
  return ret;
}
int main() {
  long long int n, m;
  scanf("%lld", &n);
  h = NTS(n);
  long long int tot = 0;
  for (long long int i = 1; i <= ((int)h.size()); i++) {
    b = i;
    memset(vis, -1, sizeof vis);
    digi[i] = dp(0, 0, 0);
    tot += digi[i];
  }
  long long int res = 0;
  digi[0] = n - tot;
  for (int j = 1; j <= ((int)h.size()); j++) {
    b = j;
    memset(vi, -1, sizeof vi);
    res = (res + digi[j] * dp1(0, 0, 0)) % 1000000007LL;
  }
  printf("%lld\n", res);
  return 0;
}