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;
const int inf = 1e9 + 100500;
const int maxn = 100500;
const int mod = 1000000007;
int add(int x, int y) { return (x + y) % mod; }
int mul(int x, int y) { return (long long)x * y % mod; }
int mpow(int x, int k) {
  if (k == 0) return 1;
  if (k == 1) return x;
  int t = mpow(mul(x, x), k / 2);
  if (k % 2) t = mul(t, x);
  return t;
}
int cnk[20][20];
void initcnk() {
  cnk[0][0] = 1;
  for (int i = 0; i < (int)(20); i++)
    if (i)
      for (int j = 0; j < (int)(i + 1); j++) {
        cnk[i][j] = cnk[i - 1][j];
        if (j) cnk[i][j] = add(cnk[i][j], cnk[i - 1][j - 1]);
      }
}
int len(int x) {
  int t = 0;
  while (x / 10) ++t, x /= 10;
  return t;
}
int getl(int x) {
  int res = 0;
  while (x) {
    res += x % 10 == 7 || x % 10 == 4;
    x /= 10;
  }
  return res;
}
int cnt[20];
int rcnt[20];
void cadd(int i, int x) {
  cnt[i] = add(cnt[i], x);
  rcnt[i] = max(rcnt[i] + x, 100);
}
void god(int x) {
  for (int i = (int)(1); i <= (int)(x); i++) cadd(getl(i), 1);
}
void go(int x, int offset) {
  int n = len(x);
  int p = mpow(10, n);
  if (n == 0) {
    int r0 = x + 1;
    int r1 = (x >= 4) + (x >= 7);
    r0 -= r1;
    cadd(0 + offset, r0);
    cadd(1 + offset, r1);
    return;
  }
  go(x % p, offset + (x / p == 4 || x / p == 7));
  for (int fd = 0; fd < (int)(x / p); fd++) {
    for (int k = (int)(0); k <= (int)(n); k++) {
      int res = mul(cnk[n][k], mul(mpow(2, k), mpow(8, n - k)));
      cadd(k + offset + (fd == 4 || fd == 7), res);
    }
  }
}
int mgo(int pos, int cur, int lim) {
  if (pos == 6) return cur;
  int res = 0;
  for (int i = 0; i < (int)(lim); i++)
    if (rcnt[i]) {
      --rcnt[i];
      int t = cnt[i];
      cadd(i, mod - 1);
      res = add(res, mgo(pos + 1, mul(cur, t), lim - i));
      ++rcnt[i];
      cadd(i, 1);
    }
  return res;
}
void solve() {
  int res = 0;
  for (int i = (int)(1); i <= (int)(10); i++)
    if (rcnt[i]) {
      --rcnt[i];
      int t = cnt[i];
      cadd(i, mod - 1);
      res = add(res, mgo(0, t, i));
      ++rcnt[i];
      cadd(i, 1);
    }
  cout << res << endl;
}
int main() {
  initcnk();
  int m;
  cin >> m;
  go(m, 0);
  cnt[0] = (cnt[0] + mod - 1) % mod;
  --rcnt[0];
  solve();
  return 0;
}