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 int MAXN = 1000 * 1 + 10, INF = 1e9 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
int m;
vector<int> getDigit(int n) {
  vector<int> v;
  while (n != 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  reverse(v.begin(), v.end());
  return v;
}
int len = 0;
long long d[100];
void build(int a, int c, int l) {
  if (c == 0) {
    if (a <= m) d[l]++;
    d[l] %= MOD;
    return;
  }
  if (c == len)
    for (int i = 1; i < 10; i++) {
      if (i == 4 || i == 7) l++;
      build(a * 10 + i, c - 1, l);
      if (i == 4 || i == 7) l--;
    }
  else
    for (int i = 0; i < 10; i++) {
      if (i == 4 || i == 7) l++;
      build(a * 10 + i, c - 1, l);
      if (i == 4 || i == 7) l--;
    }
}
long long fact(int n) {
  long long res = 1;
  for (int i = 1; i <= n; i++) res *= i;
  return res;
}
long long C(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); }
long long tmp[100][100];
void calc(int n) {
  vector<int> v = getDigit(n);
  for (int i = 0; i < 10; i++) tmp[0][i] = 1;
  for (int i = 1; i < ((int)v.size()); i++) {
    for (int j = 0; j < i; j++) {
      d[j] +=
          ((((C(i - 1, j) * (long long)pow((int)8, (int)(i - 1) - j)) % MOD) *
            7 % MOD) *
           (long long)pow((int)2, (int)j) % MOD);
      tmp[i][j] += ((C(i - 1, j) * (long long)pow((int)8, (int)(i - j)) % MOD) *
                    (long long)pow((int)2, (int)j) % MOD);
      d[j] %= MOD;
      tmp[i][j] %= MOD;
    }
    for (int j = 0; j < i; j++)
      if (j + 1 < len) {
        d[j + 1] += ((C(i - 1, j) * (long long)pow(8, (i - 1) - j) % MOD) *
                     (long long)pow(2, j + 1) % MOD);
        tmp[i][j + 1] += ((C(i - 1, j) * (long long)pow(8, (i - 1) - j) % MOD) *
                          (long long)pow(2, j + 1) % MOD);
        d[j + 1] %= MOD;
        tmp[i][j + 1] %= MOD;
      }
  }
  int cnt = 0;
  for (int i = 0; i < ((int)v.size()); i++) {
    int c = v[i], sz = ((int)v.size()) - (i + 1);
    if (i == 0) {
      for (int j = 0; j <= ((int)v.size()) - (i + 1); j++) {
        if (c > 7) {
          d[cnt + j] += (c - 3) * tmp[sz][j];
          d[cnt + j + 1] += 2 * tmp[sz][j];
        } else if (c > 4) {
          d[cnt + j] += (c - 2) * tmp[sz][j];
          d[cnt + j + 1] += tmp[sz][j];
        } else
          d[cnt + j] += (c - 1) * tmp[sz][j];
      }
    } else {
      for (int j = 0; j <= ((int)v.size()) - (i + 1); j++) {
        if (c > 7) {
          d[cnt + j] += (c - 2) * tmp[sz][j];
          d[cnt + j + 1] += 2 * tmp[sz][j];
        } else if (c > 4) {
          d[cnt + j] += (c - 1) * tmp[sz][j];
          d[cnt + j + 1] += tmp[sz][j];
        } else
          d[cnt + j] += c * tmp[sz][j];
      }
    }
    if (c == 7 || c == 4) cnt++;
  }
}
int i[10];
int main() {
  ios::sync_with_stdio(false);
  long long ans = 0;
  cin >> m;
  m++;
  len = ((int)getDigit(m).size());
  calc(m);
  for (int k = 1; k <= len; k++)
    for (i[0] = 0; i[0] <= len; i[0]++)
      for (i[1] = 0; i[1] <= len; i[1]++)
        for (i[2] = 0; i[2] <= len; i[2]++)
          for (i[3] = 0; i[3] <= len; i[3]++)
            for (i[4] = 0; i[4] <= len; i[4]++)
              for (i[5] = 0; i[5] <= len; i[5]++) {
                int sum = 0;
                long long cur = d[k];
                for (int j = 0; j < 6; j++) sum += i[j];
                if (sum >= k) continue;
                for (int j = 0; j < 6; j++) {
                  cur *= d[i[j]];
                  cur %= MOD;
                  d[i[j]]--;
                }
                for (int j = 0; j < 6; j++) d[i[j]]++;
                ans += cur;
                ans %= MOD;
              }
  cout << ans << endl;
  return 0;
}