#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline string toString(T a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <typename T>
inline long long toLong(T a) {
  long long res;
  istringstream os(a);
  os >> res;
  return res;
}
template <typename T>
inline T S(T a) {
  return a * a;
}
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline unsigned long long bigmod(T a, T b, T m) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return S(bigmod(a, b / 2, m)) % m;
  else
    return (a % m * bigmod(a, b - 1, m)) % m;
}
template <typename T>
inline vector<string> parse(T str) {
  vector<string> res;
  string s;
  istringstream os(str);
  while (os >> s) res.push_back(s);
  return res;
}
template <typename T>
inline unsigned long long dist(T A, T B) {
  unsigned long long res =
      (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
  return res;
}
template <typename T>
inline double cosAngle(T a, T b, T c) {
  double res = a * a + b * b - c * c;
  res = res / (2 * a * b);
  res = acos(res);
  return res;
}
template <typename T>
inline T power(T base, int po) {
  T res = 1;
  if (base == 0) return 0;
  for (int i = (0); i < (po); i++) res *= base;
  return res;
}
template <typename T>
inline bool isOn(T mask, T pos) {
  return mask & (1 << pos);
}
template <typename T>
inline int Off(T mask, T pos) {
  return mask ^ (1 << pos);
}
template <typename T>
inline int On(T mask, T pos) {
  return mask | (1 << pos);
}
string str;
int dp[12][2][2][12];
int memo[10][10][2];
long long res[12];
long long sum[12];
int len;
int chk(int x, int i, int choto) {
  int &ret = memo[x][i][choto];
  if (ret == -1) {
    if (choto == 1)
      ret = 1;
    else if (i <= x)
      ret = 1;
    else
      ret = 0;
  }
  return ret;
}
int solve(int pos, int choto, int flag, int baki) {
  if (baki < 0) return 0;
  if (pos == len) {
    if (flag && baki == 0) return 1;
    return 0;
  }
  int &ret = dp[pos][choto][flag][baki];
  if (ret != -1) return ret;
  ret = 0;
  int x, i;
  x = str[pos] - '0';
  for (i = 0; i <= 9; i++) {
    if (chk(x, i, choto)) {
      ret += solve(pos + 1, (choto || (i < x)), (flag || ((i != 0))),
                   baki - ((i == 4) || (i == 7)));
    }
  }
  return ret;
}
long long way[20];
long long fact[20];
long long NCR(long long n, long long r) {
  long long ret = 1;
  long long x = fact[r];
  for (long long i = n - r + 1; i <= n; i++) {
    ret *= i;
    ret %= 1000000007;
  }
  long long vag =
      bigmod(fact[r], (long long)1000000007 - 2, (long long)1000000007);
  ret *= vag;
  ret %= 1000000007;
  return ret;
}
long long rec(int pos, int sum, int baki, int lim) {
  if (sum > lim) return 0;
  if (baki == 0 && sum == lim) {
    return 1LL;
  }
  if (pos > lim) return 0;
  int i;
  long long x, y, ret = 0;
  for (i = 0; i <= baki && i <= res[pos]; i++) {
    x = rec(pos + 1, sum + i * pos, baki - i, lim);
    y = NCR(res[pos], i);
    ret = (ret + (x * y) % 1000000007) % 1000000007;
  }
  return ret;
}
int main() {
  int i, j, k;
  int ks, cas;
  cin >> str;
  len = str.length();
  memset(memo, -1, sizeof memo);
  for (i = 0; i <= 10; i++) {
    memset(dp, -1, sizeof dp);
    res[i] = solve(0, 0, 0, i);
  }
  long long ans = 0;
  sum[0] = res[0];
  fact[0] = 1;
  for (i = 1; i <= 10; i++) {
    sum[i] = sum[i - 1] + res[i];
    fact[i] = ((long long)i * fact[i - 1]) % 1000000007;
  }
  long long x, y, ret = 0;
  for (i = 1; i <= 9; i++) {
    x = rec(0, 0, 6, i - 1);
    y = (sum[10] - sum[i - 1] + 1000000007) % 1000000007;
    ret = (ret + (x * y) % 1000000007) % 1000000007;
  }
  ret = (ret * 720LL) % 1000000007;
  cout << ret << endl;
}

### Prompt

In Cpp, your task is to solve the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline string toString(T a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <typename T>
inline long long toLong(T a) {
  long long res;
  istringstream os(a);
  os >> res;
  return res;
}
template <typename T>
inline T S(T a) {
  return a * a;
}
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline unsigned long long bigmod(T a, T b, T m) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return S(bigmod(a, b / 2, m)) % m;
  else
    return (a % m * bigmod(a, b - 1, m)) % m;
}
template <typename T>
inline vector<string> parse(T str) {
  vector<string> res;
  string s;
  istringstream os(str);
  while (os >> s) res.push_back(s);
  return res;
}
template <typename T>
inline unsigned long long dist(T A, T B) {
  unsigned long long res =
      (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
  return res;
}
template <typename T>
inline double cosAngle(T a, T b, T c) {
  double res = a * a + b * b - c * c;
  res = res / (2 * a * b);
  res = acos(res);
  return res;
}
template <typename T>
inline T power(T base, int po) {
  T res = 1;
  if (base == 0) return 0;
  for (int i = (0); i < (po); i++) res *= base;
  return res;
}
template <typename T>
inline bool isOn(T mask, T pos) {
  return mask & (1 << pos);
}
template <typename T>
inline int Off(T mask, T pos) {
  return mask ^ (1 << pos);
}
template <typename T>
inline int On(T mask, T pos) {
  return mask | (1 << pos);
}
string str;
int dp[12][2][2][12];
int memo[10][10][2];
long long res[12];
long long sum[12];
int len;
int chk(int x, int i, int choto) {
  int &ret = memo[x][i][choto];
  if (ret == -1) {
    if (choto == 1)
      ret = 1;
    else if (i <= x)
      ret = 1;
    else
      ret = 0;
  }
  return ret;
}
int solve(int pos, int choto, int flag, int baki) {
  if (baki < 0) return 0;
  if (pos == len) {
    if (flag && baki == 0) return 1;
    return 0;
  }
  int &ret = dp[pos][choto][flag][baki];
  if (ret != -1) return ret;
  ret = 0;
  int x, i;
  x = str[pos] - '0';
  for (i = 0; i <= 9; i++) {
    if (chk(x, i, choto)) {
      ret += solve(pos + 1, (choto || (i < x)), (flag || ((i != 0))),
                   baki - ((i == 4) || (i == 7)));
    }
  }
  return ret;
}
long long way[20];
long long fact[20];
long long NCR(long long n, long long r) {
  long long ret = 1;
  long long x = fact[r];
  for (long long i = n - r + 1; i <= n; i++) {
    ret *= i;
    ret %= 1000000007;
  }
  long long vag =
      bigmod(fact[r], (long long)1000000007 - 2, (long long)1000000007);
  ret *= vag;
  ret %= 1000000007;
  return ret;
}
long long rec(int pos, int sum, int baki, int lim) {
  if (sum > lim) return 0;
  if (baki == 0 && sum == lim) {
    return 1LL;
  }
  if (pos > lim) return 0;
  int i;
  long long x, y, ret = 0;
  for (i = 0; i <= baki && i <= res[pos]; i++) {
    x = rec(pos + 1, sum + i * pos, baki - i, lim);
    y = NCR(res[pos], i);
    ret = (ret + (x * y) % 1000000007) % 1000000007;
  }
  return ret;
}
int main() {
  int i, j, k;
  int ks, cas;
  cin >> str;
  len = str.length();
  memset(memo, -1, sizeof memo);
  for (i = 0; i <= 10; i++) {
    memset(dp, -1, sizeof dp);
    res[i] = solve(0, 0, 0, i);
  }
  long long ans = 0;
  sum[0] = res[0];
  fact[0] = 1;
  for (i = 1; i <= 10; i++) {
    sum[i] = sum[i - 1] + res[i];
    fact[i] = ((long long)i * fact[i - 1]) % 1000000007;
  }
  long long x, y, ret = 0;
  for (i = 1; i <= 9; i++) {
    x = rec(0, 0, 6, i - 1);
    y = (sum[10] - sum[i - 1] + 1000000007) % 1000000007;
    ret = (ret + (x * y) % 1000000007) % 1000000007;
  }
  ret = (ret * 720LL) % 1000000007;
  cout << ret << endl;
}

```