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 mod = 1000000007;
long long cnt[11] = {0};
long long c[11][11] = {0};
long long dp[12][7][1000] = {0};
void f(long long a, long long len, long long mul, long long add = 0) {
  if (len == 0) {
    cnt[add] = (cnt[add] + 1) % mod;
    return;
  }
  for (long long i = 0; i < 10; i++) {
    long long iadd = 0;
    if (i == 4 || i == 7) iadd = 1;
    if (a >= (i + 1) * mul) {
      long long nluck = 1, luck = 1;
      for (int j = 1; j <= len - 1; j++) {
        nluck *= 8;
      }
      for (int j = 0; j <= len - 1; j++) {
        cnt[add + j + iadd] =
            (cnt[add + j + iadd] + (luck * nluck * c[len - 1][j]) % mod) % mod;
        luck *= 2;
        nluck /= 8;
      }
    } else {
      f(a - i * mul, len - 1, mul / 10, add + iadd);
      return;
    }
  }
}
long long rec(int k, int n, int t) {
  if (k == 11) return (n == 6);
  long long r = 0;
  long long mul = 1;
  long long val;
  for (int i = 0; i + n <= 6; i++) {
    if (i > cnt[k] || t - i * k < 0) break;
    val = (mul * c[i + n][i]) % mod;
    r = (r + (rec(k + 1, i + n, t - i * k) * val) % mod) % mod;
    mul = (mul * (cnt[k] - i)) % mod;
  }
  return r;
}
void calc(long long v) {
  for (int i = 0; i <= 11; i++) {
    for (int k = 0; k <= 6; k++) {
      for (int j = 0; j <= 10; j++) {
        dp[i][k][j] = 0;
      }
    }
  }
  dp[0][0][0] = v;
  for (int i = 0; i <= 10; i++) {
    for (int k = 0; k < 6; k++) {
      for (int j = 0; j <= 10; j++) {
        long long mul = 1;
        long long val = 1;
        for (int n = 1; n + k <= 6; n++) {
          if (n > cnt[i]) break;
          mul = (mul * (cnt[i] - (n - 1))) % mod;
          val = (mul * c[n + k][k]) % mod;
          dp[i + 1][n + k][j + i * n] =
              (dp[i + 1][n + k][j + i * n] + (dp[i][k][j] * val) % mod) % mod;
        }
      }
    }
  }
}
int main() {
  long long n;
  cin >> n;
  c[0][0] = 1;
  for (int i = 1; i <= 10; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  long long len = 1;
  long long mul = 1;
  while (mul * 10 <= n) {
    len++;
    mul *= 10;
  }
  f(n, len, mul);
  cnt[0]--;
  long long temp = 0;
  for (int i = 0; i <= 10; i++) {
    if (cnt[i] == 0) continue;
    cnt[i]--;
    calc(cnt[i] + 1);
    for (int k = 1; k <= 11; k++) {
      for (int j = 0; j < i; j++) {
      }
    }
    temp = (temp + rec(0, 0, i - 1) * (cnt[i] + 1)) % mod;
    cnt[i]++;
  }
  cout << temp;
}