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;
string s;
int n;
int len;
long long dp[10];
int memo[20][20][5];
long long mod = 1e9 + 7;
int solve(int i, int rem, int ok) {
  if (i == len) {
    return rem == 0;
  }
  int &ret = memo[i][rem][ok];
  if (ret != -1) return ret;
  ret = 0;
  for (int j = 0; j < 10; j++) {
    int c = 0;
    if (j == 4 || j == 7) c = 1;
    if (ok) {
      if (rem - c >= 0) ret += solve(i + 1, rem - c, ok);
    } else {
      if (rem - c >= 0 && j <= (s[i] - '0')) {
        if (j < (s[i] - '0'))
          ret += solve(i + 1, rem - c, 1);
        else
          ret += solve(i + 1, rem - c, 0);
      }
    }
  }
  return ret;
}
int main() {
  memset(memo, -1, sizeof(memo));
  cin >> n;
  int x = n;
  while (x > 0) {
    s += char('0' + x % 10);
    x = x /= 10;
  }
  reverse(s.begin(), s.end());
  len = s.length();
  for (int i = 0; i < 10; i++) {
    dp[i] = solve(0, i, 0);
  }
  dp[0]--;
  long long res = 0;
  for (int p1 = 0; p1 < 10; p1++) {
    long long cnt[7] = {0};
    cnt[0] = dp[p1];
    if (dp[p1] == 0) continue;
    dp[p1]--;
    for (int p2 = 0; p2 < 10; p2++) {
      if (dp[p2] == 0) continue;
      cnt[1] = dp[p2] * cnt[0];
      cnt[1] %= mod;
      dp[p2]--;
      for (int p3 = 0; p3 < 10; p3++) {
        if (dp[p3] == 0) continue;
        cnt[2] = dp[p3] * cnt[1];
        cnt[2] %= mod;
        dp[p3]--;
        for (int p4 = 0; p4 < 10; p4++) {
          if (dp[p4] == 0) continue;
          cnt[3] = dp[p4] * cnt[2];
          cnt[3] %= mod;
          dp[p4]--;
          for (int p5 = 0; p5 < 10; p5++) {
            if (dp[p5] == 0) continue;
            cnt[4] = dp[p5] * cnt[3];
            cnt[4] %= mod;
            dp[p5]--;
            for (int p6 = 0; p6 < 10; p6++) {
              if (dp[p6] == 0) continue;
              cnt[5] = dp[p6] * cnt[4];
              cnt[5] %= mod;
              dp[p6]--;
              for (int p7 = 0; p7 < 10; p7++) {
                if (dp[p7] == 0) continue;
                cnt[6] = dp[p7] * cnt[5];
                cnt[6] %= mod;
                if (p1 > p2 + p3 + p4 + p5 + p6 + p7) res += cnt[6];
                res %= mod;
              }
              dp[p6]++;
            }
            dp[p5]++;
          }
          dp[p4]++;
        }
        dp[p3]++;
      }
      dp[p2]++;
    }
    dp[p1]++;
  }
  cout << res << endl;
}