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;
template <typename T>
string toString(T x) {
  if (x == 0) return "0";
  bool negative = x < 0;
  string res;
  while (x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  if (negative) res.push_back('-');
  reverse(res.begin(), res.end());
  return res;
}
template <typename T>
T gcd(T a, T b) {
  return a == 0 ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const long long MOD = 1000000007;
int n;
int num[10];
int comb[11][11];
int digitsNum[10][10];
void calcNum() {
  if (n == 1000000000) {
    for (int i = 0; i < 10; i++) {
      num[i] = digitsNum[9][i];
    }
    return;
  }
  int ceil = 9;
  int numd = 1;
  while (ceil < n) {
    numd++;
    ceil *= 10;
    ceil += 9;
  }
  for (int i = 0; i < 10; i++) {
    num[i] = digitsNum[numd][i];
  }
  int decr = 1;
  numd--;
  for (int i = 0; i < numd; i++) {
    decr *= 10;
  }
  int luckoffset = 0;
  while (ceil > n) {
    int atLastDigit = 9;
    while (ceil - decr >= n) {
      ceil -= decr;
      if (atLastDigit == 4 || atLastDigit == 7) {
        luckoffset++;
      }
      for (int i = 0; i < 10; i++) {
        num[i + luckoffset] -= digitsNum[numd][i];
      }
      if (atLastDigit == 4 || atLastDigit == 7) {
        luckoffset--;
      }
      atLastDigit--;
    }
    if (atLastDigit == 4 || atLastDigit == 7) {
      luckoffset++;
    }
    numd--;
    decr /= 10;
  }
  num[0]--;
}
int main() {
  comb[0][0] = 1;
  for (int y = 1; y <= 10; y++) {
    comb[y][0] = 1;
    comb[y][y] = 1;
    for (int x = 1; x < y; x++) {
      comb[y][x] = comb[y - 1][x - 1] + comb[y - 1][x];
    }
  }
  digitsNum[0][0] = 1;
  for (int numd = 1; numd < 10; numd++) {
    for (int luck = 0; luck <= numd; luck++) {
      int& cur = digitsNum[numd][luck];
      cur = 1;
      for (int i = 0; i < luck; i++) {
        cur *= 2;
      }
      for (int i = luck; i < numd; i++) {
        cur *= 8;
      }
      cur *= comb[numd][luck];
    }
  }
  cin >> n;
  calcNum();
  long long res = 0;
  int onum[10] = {0};
  int otot = 0;
  for (int me = 1; me <= 9; me++) {
    num[me]--;
    for (int o1 = 0; o1 <= 9; o1++) {
      otot += o1;
      onum[o1]++;
      for (int o2 = 0; o2 <= 9; o2++) {
        otot += o2;
        onum[o2]++;
        for (int o3 = 0; o3 <= 9; o3++) {
          otot += o3;
          onum[o3]++;
          for (int o4 = 0; o4 <= 9; o4++) {
            otot += o4;
            onum[o4]++;
            for (int o5 = 0; o5 <= 9; o5++) {
              otot += o5;
              onum[o5]++;
              for (int o6 = 0; o6 <= 9; o6++) {
                otot += o6;
                onum[o6]++;
                if (otot < me) {
                  long long cur = num[me] + 1;
                  for (int d = 0; d <= 9; d++) {
                    for (int i = 0; i < onum[d]; i++) {
                      cur *= (num[d] - i);
                      cur %= MOD;
                    }
                  }
                  res += cur;
                  res %= MOD;
                }
                otot -= o6;
                onum[o6]--;
              }
              otot -= o5;
              onum[o5]--;
            }
            otot -= o4;
            onum[o4]--;
          }
          otot -= o3;
          onum[o3]--;
        }
        otot -= o2;
        onum[o2]--;
      }
      otot -= o1;
      onum[o1]--;
    }
    num[me]++;
  }
  cout << res;
  return 0;
}