#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T S(T a) {
  return a * a;
}
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 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;
}
string str;
long long dp[15][15][15][2];
int LEN;
long long solve(int pos, int baki, int idx, bool choto) {
  if (pos == LEN) {
    if (baki != 0)
      return 0;
    else
      return 1;
  }
  long long &ret = dp[pos][idx][baki][choto];
  if (ret != -1) return ret;
  ret = 0;
  int l, h;
  h = 9;
  if (choto == 0) {
    h = str[pos] - '0';
  }
  bool ns;
  int i;
  for (i = 0; i <= h; i++) {
    ns = 0;
    if (choto || i < h) ns = 1;
    if ((i == 4 || i == 7) && (baki > 0)) {
      ret = (ret + solve(pos + 1, baki - 1, i, ns)) % 1000000007;
    } else {
      ret = (ret + solve(pos + 1, baki, i, ns)) % 1000000007;
    }
    ret %= 1000000007;
  }
  return ret;
}
long long ans[20];
long long fact[10];
long long dp2[20][20][20];
long long res[20];
long long calc(int ind, int nisi) {
  cout << ind << " *** " << nisi << endl;
  long long x = ans[ind];
  cout << ans[ind] << endl;
  if (ans[ind] < nisi) {
    x = ans[ind] + 1000000007;
  }
  long long res = 1;
  long long mx = (nisi > x - nisi ? nisi : x - nisi);
  cout << mx << " " << x << endl;
  for (long long i = mx + 1; i <= x; i++) {
    res = res * i;
    res %= 1000000007;
  }
  cout << res << endl;
  return res;
}
long long anss = 0;
void find(int now, long long cur, int n) {
  if (n == 0) {
    anss = (anss + cur) % 1000000007;
    return;
  } else {
    for (int i = 0; i <= now; i++) {
      if (ans[i] != 0) {
        ans[i]--;
        find(now - i, (cur * (ans[i] + 1)) % 1000000007, n - 1);
        ans[i]++;
      }
    }
  }
}
long long solve1(int pos, int dol, int baki, int p) {
  if (dol == 0) {
    cout << "sadf";
    return 720;
  }
  if (baki < pos * dol) return 0;
  long long &res = dp2[pos][dol][baki];
  if (res != -1) return res;
  res = 0;
  for (int i = 1; i <= dol; i++) {
    if (baki - (i * pos) >= 0) {
      res += calc(pos, i) * solve1(pos + 1, dol - i, baki - (i * pos), p);
    }
  }
  return res;
}
int main() {
  int i, j, k;
  fact[0] = fact[1] = 1;
  for (i = 2; i <= 6; i++) {
    fact[i] = i * fact[i - 1];
  }
  int n;
  cin >> n;
  str = tostring(n);
  for (i = 0; i <= LEN; i++) {
    memset(dp, -1, sizeof dp);
    LEN = str.length();
    ans[i] = solve(0, i, 0, 0);
  }
  ans[0] = ans[0] - 1;
  for (i = 0; i <= LEN; i++) {
    ans[i] = ans[i] - ans[i + 1];
    if (ans[i] < 0) ans[i] += 1000000007;
    if (ans[i] < 0) ans[i] += 1000000007;
  }
  long long res = 0;
  for (int i = 1; i <= 9; i++) {
    if (ans[i] != 0) find(i - 1, ans[i], 6);
  }
  cout << anss << endl;
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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 T S(T a) {
  return a * a;
}
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 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;
}
string str;
long long dp[15][15][15][2];
int LEN;
long long solve(int pos, int baki, int idx, bool choto) {
  if (pos == LEN) {
    if (baki != 0)
      return 0;
    else
      return 1;
  }
  long long &ret = dp[pos][idx][baki][choto];
  if (ret != -1) return ret;
  ret = 0;
  int l, h;
  h = 9;
  if (choto == 0) {
    h = str[pos] - '0';
  }
  bool ns;
  int i;
  for (i = 0; i <= h; i++) {
    ns = 0;
    if (choto || i < h) ns = 1;
    if ((i == 4 || i == 7) && (baki > 0)) {
      ret = (ret + solve(pos + 1, baki - 1, i, ns)) % 1000000007;
    } else {
      ret = (ret + solve(pos + 1, baki, i, ns)) % 1000000007;
    }
    ret %= 1000000007;
  }
  return ret;
}
long long ans[20];
long long fact[10];
long long dp2[20][20][20];
long long res[20];
long long calc(int ind, int nisi) {
  cout << ind << " *** " << nisi << endl;
  long long x = ans[ind];
  cout << ans[ind] << endl;
  if (ans[ind] < nisi) {
    x = ans[ind] + 1000000007;
  }
  long long res = 1;
  long long mx = (nisi > x - nisi ? nisi : x - nisi);
  cout << mx << " " << x << endl;
  for (long long i = mx + 1; i <= x; i++) {
    res = res * i;
    res %= 1000000007;
  }
  cout << res << endl;
  return res;
}
long long anss = 0;
void find(int now, long long cur, int n) {
  if (n == 0) {
    anss = (anss + cur) % 1000000007;
    return;
  } else {
    for (int i = 0; i <= now; i++) {
      if (ans[i] != 0) {
        ans[i]--;
        find(now - i, (cur * (ans[i] + 1)) % 1000000007, n - 1);
        ans[i]++;
      }
    }
  }
}
long long solve1(int pos, int dol, int baki, int p) {
  if (dol == 0) {
    cout << "sadf";
    return 720;
  }
  if (baki < pos * dol) return 0;
  long long &res = dp2[pos][dol][baki];
  if (res != -1) return res;
  res = 0;
  for (int i = 1; i <= dol; i++) {
    if (baki - (i * pos) >= 0) {
      res += calc(pos, i) * solve1(pos + 1, dol - i, baki - (i * pos), p);
    }
  }
  return res;
}
int main() {
  int i, j, k;
  fact[0] = fact[1] = 1;
  for (i = 2; i <= 6; i++) {
    fact[i] = i * fact[i - 1];
  }
  int n;
  cin >> n;
  str = tostring(n);
  for (i = 0; i <= LEN; i++) {
    memset(dp, -1, sizeof dp);
    LEN = str.length();
    ans[i] = solve(0, i, 0, 0);
  }
  ans[0] = ans[0] - 1;
  for (i = 0; i <= LEN; i++) {
    ans[i] = ans[i] - ans[i + 1];
    if (ans[i] < 0) ans[i] += 1000000007;
    if (ans[i] < 0) ans[i] += 1000000007;
  }
  long long res = 0;
  for (int i = 1; i <= 9; i++) {
    if (ans[i] != 0) find(i - 1, ans[i], 6);
  }
  cout << anss << endl;
  return 0;
}

```