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;
vector<int> dig;
int cnt[13];
void getDig(int m) {
  if (m > 9) getDig(m / 10);
  dig.push_back(m % 10);
}
long long mod = 1000000007, ans, dp[13][13];
long long An6(int n) {
  if (n < 6) return 0LL;
  long long mu = 1;
  for (int i = 1; i <= 6; ++i) mu = (mu * (n - i + 1)) % mod;
  return mu;
}
int pow(int a, int n) {
  int r = 1;
  while (n) {
    if (n & 1) r *= a;
    a *= a;
    n >>= 1;
  }
  return r;
}
int C[111][111];
long long c1[11];
long long df;
int lim;
void dfs(int dep, int sum, long long v) {
  if (sum > lim) return;
  if (dep == 6) {
    df = (df + v) % mod;
    return;
  }
  for (int i = 0; i + sum < lim; ++i) {
    if (c1[i]) {
      long long v1 = (v * c1[i]) % mod;
      --c1[i];
      dfs(dep + 1, sum + i, v1);
      ++c1[i];
    }
  }
}
int main() {
  int m, i, j, k, len;
  for (i = 0; i < 100; ++i) {
    C[i][0] = 1;
    for (j = 1; j <= i; ++j) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  while (scanf("%d", &m) != EOF) {
    memset(dp, 0, sizeof(dp));
    memset(cnt, 0, sizeof(cnt));
    ++m;
    dig.clear();
    getDig(m);
    len = dig.size();
    dp[1][0] = 7;
    dp[1][1] = 2;
    for (i = 2; i < len; ++i) {
      for (j = 0; j <= 9; ++j) {
        for (k = 0; k < i; ++k) {
          dp[i][k + (j == 4 || j == 7)] += dp[i - 1][k];
        }
      }
    }
    for (i = 1; i < len; ++i) {
      for (j = 1; j <= i; ++j) {
        cnt[j] += dp[i][j];
      }
    }
    int now = 0;
    for (i = 0; i < len; ++i) {
      for (j = (i == 0 ? 1 : 0); j < dig[i]; ++j) {
        for (k = 0; k + i < len; ++k) {
          cnt[k + now + (j == 4 || j == 7)] +=
              pow(2, k) * pow(8, len - i - 1 - k) * C[len - i - 1][k];
        }
      }
      now += (j == 4 || j == 7);
    }
    int sum = 0;
    ans = 0;
    cnt[0] = m - 1;
    for (i = 1; i < 11; ++i) cnt[0] -= cnt[i];
    for (i = 0; i < 11; ++i) {
      for (j = 0; j < 11; ++j) c1[i] = cnt[i];
      df = 0;
      lim = i;
      dfs(0, 0, 1LL);
      ans = (ans + 1LL * df * cnt[i]) % mod;
      sum += cnt[i];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}