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>
int mod = 1000000007;
int a[16];
int s[10];
int m2[10], m8[10];
int c[10][10];
int res;
int ff[7];
int rr[7];
int cc(int x, int y) {
  int i;
  for (i = 0; i < y; i++) rr[i] = s[x] - i;
  if (y >= 2) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
  }
  if (y >= 3) {
    for (i = 0; i < y; i++)
      if (rr[i] % 3 == 0) {
        rr[i] = rr[i] / 3;
        break;
      }
  }
  if (y >= 4) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
  }
  if (y >= 5) {
    for (i = 0; i < y; i++)
      if (rr[i] % 5 == 0) {
        rr[i] = rr[i] / 5;
        break;
      }
  }
  if (y >= 6) {
    for (i = 0; i < y; i++)
      if (rr[i] % 2 == 0) {
        rr[i] = rr[i] / 2;
        break;
      }
    for (i = 0; i < y; i++)
      if (rr[i] % 3 == 0) {
        rr[i] = rr[i] / 3;
        break;
      }
  }
  long long ret = 1;
  for (i = 0; i < y; i++) ret = (ret * rr[i]) % mod;
  return (int)ret;
}
void cal(int x) {
  int i, j;
  long long ret = s[x];
  for (i = 1; i <= 6;) {
    j = i;
    while (i <= 6 && ff[i] == ff[j]) i++;
    ret = (ret * cc(ff[j], i - j)) % mod;
  }
  res = (res + ret * 720) % mod;
}
void dfs(int x, int pr, int tot, int cur) {
  if (x == 7)
    cal(cur);
  else {
    int i;
    if (pr < tot)
      i = pr;
    else
      i = tot;
    for (; i >= 0; i--) {
      ff[x] = i;
      dfs(x + 1, i, tot - i, cur);
    }
  }
}
int main() {
  int m, l;
  int i, j, k, r;
  scanf("%d", &m);
  l = 0;
  while (m > 0) {
    l++;
    a[l] = m % 10;
    m = m / 10;
  }
  memset(s, 0, sizeof(s));
  m2[0] = 1;
  m8[0] = 1;
  for (i = 1; i <= 9; i++) {
    m2[i] = m2[i - 1] * 2;
    m8[i] = m8[i - 1] * 8;
  }
  c[0][0] = 1;
  c[1][0] = 1;
  c[1][1] = 1;
  for (i = 2; i <= 9; i++) {
    c[i][0] = 1;
    for (j = 1; j <= i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  k = 0;
  for (i = l; i >= 1; i--) {
    for (j = 0; j < a[i]; j++) {
      if (j == 4 || j == 7) {
        for (r = 0; r <= i - 1; r++)
          s[r + 1 + k] = s[r + 1 + k] + c[i - 1][r] * m2[r] * m8[i - 1 - r];
      } else {
        for (r = 0; r <= i - 1; r++)
          s[r + k] = s[r + k] + c[i - 1][r] * m2[r] * m8[i - 1 - r];
      }
    }
    if (a[i] == 4 || a[i] == 7) k++;
  }
  s[k]++;
  s[0]--;
  res = 0;
  for (i = 1; i <= l; i++) dfs(1, i - 1, i - 1, i);
  printf("%d\n", res);
  return 0;
}