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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int MOD = (int)1e9 + 7;
int cnt[11], m, d[11], len;
int dp[11][11][2];
int dfs(int pos, int ost, int lower) {
  if (ost < 0) return 0;
  if (pos == -1) {
    if (ost == 0) return 1;
    return 0;
  } else {
    int &res = dp[pos][ost][lower];
    if (res != -1) return res;
    res = 0;
    if (lower) {
      res += 2 * dfs(pos - 1, ost - 1, lower);
      res += 8 * dfs(pos - 1, ost, lower);
    } else {
      for (int i = 0; i < d[pos]; i++) {
        if (i == 4 || i == 7)
          res += dfs(pos - 1, ost - 1, 1);
        else
          res += dfs(pos - 1, ost, 1);
      }
      if (d[pos] == 4 || d[pos] == 7)
        res += dfs(pos - 1, ost - 1, 0);
      else
        res += dfs(pos - 1, ost, 0);
    }
    return res;
  }
}
int num[8];
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> m;
  len = 0;
  while (m > 0) {
    d[len++] = m % 10;
    m /= 10;
  }
  for (int i = len; i >= 0; i--) {
    cnt[i] = dfs(len - 1, i, 0);
  }
  cnt[0]--;
  int res = 0;
  for (int i = 1; i <= len; i++) {
    int cur = cnt[i];
    for (num[0] = 0; num[0] < i; num[0]++) {
      if (cnt[num[0]] <= 0) continue;
      int cur1 = (long long)cur * cnt[num[0]] % MOD;
      cnt[num[0]]--;
      for (num[1] = 0; num[0] + num[1] < i; num[1]++) {
        if (cnt[num[1]] <= 0) continue;
        int cur2 = (long long)cur1 * cnt[num[1]] % MOD;
        cnt[num[1]]--;
        for (num[2] = 0; num[0] + num[1] + num[2] < i; num[2]++) {
          if (cnt[num[2]] <= 0) continue;
          int cur3 = (long long)cur2 * cnt[num[2]] % MOD;
          cnt[num[2]]--;
          for (num[3] = 0; num[0] + num[1] + num[2] + num[3] < i; num[3]++) {
            if (cnt[num[3]] <= 0) continue;
            int cur4 = (long long)cur3 * cnt[num[3]] % MOD;
            cnt[num[3]]--;
            for (num[4] = 0; num[0] + num[1] + num[2] + num[3] + num[4] < i;
                 num[4]++) {
              if (cnt[num[4]] <= 0) continue;
              int cur5 = (long long)cur4 * cnt[num[4]] % MOD;
              cnt[num[4]]--;
              for (num[5] = 0;
                   num[0] + num[1] + num[2] + num[3] + num[4] + num[5] < i;
                   num[5]++) {
                if (cnt[num[5]] <= 0) continue;
                int cur6 = (long long)cur5 * cnt[num[5]] % MOD;
                res = (res + cur6) % MOD;
              }
              cnt[num[4]]++;
            }
            cnt[num[3]]++;
          }
          cnt[num[2]]++;
        }
        cnt[num[1]]++;
      }
      cnt[num[0]]++;
    }
  }
  cout << res << endl;
  return 0;
}