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>
long long modulo = 1000000007;
int SUM = 0;
int values[9] = {6, 0, 0, 0, 0, 0, 0, 0, 0};
int factorial[7] = {1, 1, 2, 6, 24, 120, 720};
void simplify() {
  values[0] = 6;
  for (int i = 1; i < 9; i++) values[i] = 0;
}
int getSum(int start) {
  int summ = 0;
  for (int i = start; i < 9; i++) summ += values[i] * i;
  return summ;
}
int getNum(int start) {
  int summ = 0;
  for (int i = start; i < 9; i++) summ += values[i];
  return summ;
}
bool nextVal() {
  for (int i = 1; i < 9; i++) {
    values[i]++;
    if (getSum(i) < SUM && getNum(i) < 7) {
      int k = 6 - getNum(i);
      for (int j = 0; j < i; j++) values[j] = 0;
      values[0] = k;
      return true;
    }
    values[i]--;
  }
  return false;
}
int main(int argc, const char* argv[]) {
  int m, M[10];
  long long K[10][10], res[10], result = 0;
  scanf("%d", &m);
  bool wasModified = false;
  if (m == 1000000000) {
    m--;
    wasModified = true;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) K[i][j] = 0;
    M[i] = 0;
    res[i] = 0;
  }
  K[1][1] = 2;
  K[1][0] = 8;
  for (int i = 2; i < 10; i++)
    for (int j = 0; j <= i; j++)
      if (j == 0) {
        K[i][j] = K[i - 1][j] * 8;
      } else
        K[i][j] = K[i - 1][j] * 8 + K[i - 1][j - 1] * 2;
  int p = 0, hn = 0;
  for (; m > 0; p++) {
    M[p] = m % 10;
    m /= 10;
  }
  p--;
  for (; p >= 0; p--) {
    for (int i = 0; i < 10; i++) {
      int MP = M[p];
      if (MP < 1) continue;
      if (M[p] <= 4)
        res[i + hn] += K[p][i] * MP;
      else if (M[p] <= 7) {
        res[i + hn] += K[p][i] * (MP - 1);
        res[i + 1 + hn] += K[p][i];
      } else {
        res[i + hn] += K[p][i] * (MP - 2);
        res[i + 1 + hn] += 2 * K[p][i];
      }
    }
    if ((M[p] == 4 || M[p] == 7) && p > 0) hn++;
  }
  if (M[0] < 4)
    res[hn] += M[0] + 1;
  else if (M[0] < 7) {
    res[hn] += M[0];
    res[hn + 1] += 1;
  } else {
    res[hn] += M[0] - 1;
    res[hn + 1] += 2;
  }
  if (!wasModified) res[0]--;
  for (int i = 9; i > 0; i--) {
    long long dod = 1;
    if (res[i] < 1) continue;
    SUM = i;
    simplify();
    long long mnoj[6];
    do {
      dod = 1;
      int J = 0;
      for (int k = 0; k < 9; k++)
        for (int j = 0; j < values[k]; j++, J++) mnoj[J] = res[k] - j;
      for (int j = 0; j < 6; j++) dod = (dod * mnoj[j]) % modulo;
      int factor = factorial[6];
      for (int i = 0; i < 9; i++) factor /= factorial[values[i]];
      dod = (dod * factor) % modulo;
      dod = (dod * res[i]) % modulo;
      result = (result + dod) % modulo;
    } while (nextVal());
  }
  std::cout << result;
  return 0;
}