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 base = 1000000007;
int m, mm, sz;
long long dp[20][20][2];
int mr[20];
long long A(int x, int y) {
  long long ans = 1;
  for (long long i = x; i >= x - y + 1; i--) {
    ans = ans * i;
    ans %= base;
  }
  return ans;
}
long long bin(long long x, long long y) {
  if (y == 0) return 1;
  long long u = bin(x, y / 2);
  if (y % 2 == 0) {
    return u * u % base;
  } else {
    return u * u % base * x % base;
  }
}
long long C(int x, int y) {
  long long ans = 1;
  for (long long i = x; i >= x - y + 1; i--) ans = ans * i, ans %= base;
  for (int i = 1; i <= y; i++) ans = ans * bin(i, base - 2), ans %= base;
  return ans;
}
long long f[30][30][30];
long long glans = 0;
long long pr[100];
int pr2[100];
int main() {
  cin >> m;
  mm = m;
  while (mm > 0) {
    sz++;
    mm /= 10;
  }
  mm = m;
  for (int i = sz; i > 0; i--) {
    mr[i] = mm % 10;
    mm /= 10;
  }
  dp[0][0][1] = 1;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j <= 12; j++) {
      for (int z = 0; z < 2; z++) {
        for (int next = 0; next < 10; next++) {
          if (z == 0) {
            if (next != 4 && next != 7) {
              dp[i + 1][j][z] += dp[i][j][z];
            } else {
              dp[i + 1][j + 1][z] += dp[i][j][z];
            }
          } else {
            if (next == mr[i + 1]) {
              if (next == 4 || next == 7) {
                dp[i + 1][j + 1][z] += dp[i][j][z];
              } else {
                dp[i + 1][j][z] += dp[i][j][z];
              }
            }
            if (next < mr[i + 1]) {
              if (next == 4 || next == 7) {
                dp[i + 1][j + 1][0] += dp[i][j][z];
              } else {
                dp[i + 1][j][0] += dp[i][j][z];
              }
            }
          }
        }
      }
    }
  }
  for (int i = 0; i <= sz; i++) pr[i] = (dp[sz][i][0] + dp[sz][i][1]) % base;
  pr[0]--;
  for (int i = 0; i <= 6; i++) f[0][i][0] = C(pr[0], i);
  for (int i = 1; i <= sz; i++) {
    f[i][0][0] = 1;
    for (int j = 1; j <= 6; j++) {
      for (int z = 0; z <= sz; z++) {
        for (int e = 0; e <= j && e * i <= z; e++) {
          f[i][j][z] += f[i - 1][j - e][z - e * i] * C(pr[i], e);
          f[i][j][z] %= base;
        }
      }
    }
  }
  for (int i = 0; i <= sz; i++) {
    long long zz = 720;
    long long ee = f[sz][6][i] * zz;
    ee %= base;
    for (int j = i + 1; j <= sz; j++) {
      glans = glans + ee * pr[j];
      glans %= base;
    }
  }
  cout << glans << endl;
  return 0;
}