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;
long long fpm(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) { adj[s].erase(find(iter(adj[s]), e)); }
  int deg(int v) { return adj[v].size(); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
const int maxL = 30, mod = 1000000007;
long long v[maxL];
long long cb[maxL][maxL];
void dfs(long long m, long long div, long long bef, long long len,
         long long cnt) {
  if (div == 0) {
    ++v[cnt];
    return;
  }
  long long x = m / div % 10;
  if (m / div / 10 != bef) {
    for (long long i = 0; i <= len; ++i)
      v[i + cnt] += cb[len][i] * fpm(2, i, mod) * fpm(8, len - i, mod);
    return;
  }
  for (long long i = 0; i <= x; ++i)
    dfs(m, div / 10, bef * 10 + i, len - 1, cnt + (i == 4 || i == 7));
}
long long inv[maxL];
long long ans = 0;
void search(long long d, long long sum = 1, long long cnt = 1,
            long long rem = 6) {
  if (rem == 0) {
    for (; sum < maxL && v[sum]; ++sum) (ans += cnt * v[sum]) %= mod;
    return;
  }
  if (sum >= maxL || !v[sum] || (rem && !v[d])) return;
  for (long long i = 0; i <= rem; ++i) {
    search(d + 1, sum + i * d, cnt * cb[rem][i] % mod, rem - i);
    cnt = cnt * (mod + v[d] - i) % mod;
  }
}
long long calc(long long x) {
  long long ret = 0;
  for (; x; x /= 10) ret += x % 10 == 4 || x % 10 == 7;
  return ret;
}
long long w[20];
int main() {
  ios_base::sync_with_stdio(false);
  long long m;
  for (long long i = 0; i <= 20; ++i)
    for (long long j = 0; j <= i; ++j)
      cb[i][j] = j ? cb[i - 1][j - 1] + cb[i - 1][j] : 1;
  inv[1] = 1;
  for (long long i = 2; i <= 20; ++i)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  cin >> m;
  dfs(m, 1e9, 0, 10, 0), --v[0];
  for (long long i = 0; i <= 10; ++i) cerr << v[i] << endl;
  search(0);
  cout << ans % mod << endl;
  return 0;
}