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;
const long long mod = (long long)1e9 + 7;
int p2[15], p8[15], p10[15], dp[15][15], c[15][15], pd[15];
int m, cs;
long long res;
int countLuck(int x) {
  int res = 0;
  while (x) {
    if (x % 10 == 4 || x % 10 == 7) res++;
    x /= 10;
  }
  return res;
}
int countCs(int x) {
  int res = 0;
  while (x) res++, x /= 10;
  return res;
}
void calculateTohop() {
  c[0][0] = 1;
  for (int i = 1; i <= cs; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
}
void init() {
  cs = countCs(m);
  calculateTohop();
  p2[0] = p8[0] = 1;
  for (int i = 1; i <= cs; i++) {
    p2[i] = p2[i - 1] * 2, p8[i] = p8[i - 1] * 8;
    if (i < cs) dp[i][i] += p2[i];
    if (i < cs) dp[i][0] += p8[i - 1] * 7;
  }
  dp[0][0] = 1;
  for (int len = 1; len < cs; len++)
    for (int x = 1; x < len; x++) {
      int y = len - x;
      int res1 = c[len - 1][x - 1] * p8[x - 1] * 7 * p2[y];
      int res2 = c[len - 1][y - 1] * p2[y] * p8[x];
      dp[len][y] += res1 + res2;
    }
}
void calLast() {
  int start, cntLuck = 0, tmp;
  p10[0] = 1;
  for (int i = 1; i < cs; i++) p10[i] = p10[i - 1] * 10;
  for (int i = 1; i <= cs; i++) {
    int x = (m / p10[cs - i]) % 10;
    if (i == 1)
      start = 1;
    else
      start = 0;
    for (int j = start; j < x; j++) {
      if (j == 4 || j == 7)
        tmp = 1;
      else
        tmp = 0;
      for (int k = 0; k <= cs - cntLuck - tmp; k++) {
        for (int l = 0; l <= cs - i; l++)
          dp[cs][cntLuck + tmp + k] += dp[cs - i - l][k];
      }
    }
    if (x == 4 || x == 7) cntLuck++;
  }
  dp[cs][countLuck(m)]++;
}
long long mult(long long a, long long b) { return (a * b) % mod; }
void solve() {
  for (int i = 1; i <= cs; i++)
    for (int j = 0; j <= cs; j++) pd[j] += dp[i][j];
  int bb[15];
  long long tmp;
  for (int x1 = 1; x1 <= cs; x1++) {
    for (int x2 = 0; x2 <= x1 - 1; x2++)
      for (int x3 = 0; x3 <= x1 - 1 - x2; x3++)
        for (int x4 = 0; x4 <= x1 - 1 - x2 - x3; x4++)
          for (int x5 = 0; x5 <= x1 - 1 - x2 - x3 - x4; x5++)
            for (int x6 = 0; x6 <= x1 - 1 - x2 - x3 - x4 - x5; x6++)
              for (int x7 = 0; x7 <= x1 - 1 - x2 - x3 - x4 - x5 - x6; x7++) {
                memset(bb, 0, sizeof bb);
                tmp = mult(pd[x1], pd[x2]);
                bb[x2]++;
                tmp = mult(tmp, (pd[x3] - bb[x3]));
                bb[x3]++;
                tmp = mult(tmp, (pd[x4] - bb[x4]));
                bb[x4]++;
                tmp = mult(tmp, (pd[x5] - bb[x5]));
                bb[x5]++;
                tmp = mult(tmp, (pd[x6] - bb[x6]));
                bb[x6]++;
                tmp = mult(tmp, (pd[x7] - bb[x7]));
                res = (res + tmp) % mod;
              }
  }
  cout << res << endl;
}
int main() {
  if (0) {
    freopen("a.inp", "r", stdin);
    freopen("a.out", "w", stdout);
  };
  scanf("%d", &m);
  init();
  calLast();
  solve();
}