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 B = 1e9 + 7;
int m;
int cnt[10];
int k;
int dig[10];
long long dp[10][10];
int vis[10][10];
int get(int i, int j) {
  if (j < 0 || i < 0) return 0;
  if (j == 0 && i == 0) return dp[i][j] = 1;
  if (vis[i][j]) return dp[i][j];
  vis[i][j] = 1;
  return dp[i][j] = (4LL * get(i, j - 1) + 1LL * get(i - 1, j - 1) +
                     2LL * get(i, j - 1) + 1LL * get(i - 1, j - 1) +
                     2LL * get(i, j - 1)) %
                    B;
}
long long solve(int p) {
  int n = p + 5;
  long long res = 0;
  for (int i1 = 1; i1 <= n; ++i1) {
    for (int i2 = i1 + 1; i2 <= n; ++i2) {
      for (int i3 = i2 + 1; i3 <= n; ++i3) {
        for (int i4 = i3 + 1; i4 <= n; ++i4) {
          for (int i5 = i4 + 1; i5 <= n; ++i5) {
            int cc[10];
            memset(cc, 0, sizeof(cc));
            cc[i1 - 1]++;
            cc[i2 - i1 - 1]++;
            cc[i3 - i2 - 1]++;
            cc[i4 - i3 - 1]++;
            cc[i5 - i4 - 1]++;
            cc[n + 1 - i5 - 1]++;
            long long tmp = 1;
            for (int i = 0; i < 10; ++i) {
              int t = cnt[i];
              while (cc[i] && tmp) {
                tmp = tmp * t % B;
                cc[i]--;
                t--;
              }
            }
            res += tmp;
          }
        }
      }
    }
  }
  return res;
}
int main() {
  scanf("%d", &m);
  int t = m;
  while (t) {
    dig[k++] = t % 10;
    t /= 10;
  }
  for (int i = 0; i <= 9; ++i) {
    t = 0;
    for (int j = k - 1; j >= 0; --j) {
      int ti = i - t;
      if (dig[j] <= 4) {
        cnt[i] += dig[j] * get(ti, j);
      } else if (dig[j] <= 7) {
        cnt[i] +=
            4 * get(ti, j) + 1 * get(ti - 1, j) + (dig[j] - 5) * get(ti, j);
      } else {
        cnt[i] += 4 * get(ti, j) + 1 * get(ti - 1, j) + 2 * get(ti, j) +
                  1 * get(ti - 1, j) + (dig[j] - 8) * get(ti, j);
      }
      if (dig[j] == 4 || dig[j] == 7) {
        t++;
      }
    }
  }
  cnt[0]--;
  cnt[t]++;
  long long ans = 0;
  for (int i = 1; i <= 9; ++i) {
    long long tmp = cnt[i];
    cnt[i]--;
    long long tt = 0;
    for (int j = 0; j < i; ++j) {
      tt += solve(j);
    }
    cnt[i]++;
    tmp = tmp * tt % B;
    ans = (ans + tmp) % B;
  }
  printf("%I64d\n", ans);
  return 0;
}