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
#include <bits/stdc++.h>
using namespace std;
const int M = 10 + 10;
int minn0[M][M];
int minn[M][M];
int dig[M];
int dignum;
int fac(int x) {
  int ans = 1;
  for (int i = 1; i <= x; i++) {
    ans = ans * i;
  }
  return ans;
}
int ex(int a, int x) {
  int ans = 1;
  for (int i = 1; i <= x; i++) {
    ans = ans * a;
  }
  return ans;
}
void mluckyinn0() {
  for (int n = 1; n <= 9; n++) {
    for (int m = 0; m <= n; m++) {
      minn0[0][m] = 1;
      int nchm = fac(n) / fac(m) / fac(n - m);
      int lucky = ex(2, m);
      int unlucky = ex(8, n - m);
      minn0[n][m] = nchm * lucky * unlucky;
    }
  }
}
void mluckyinn() {
  minn[1][0] = 7;
  minn[1][1] = 2;
  for (int n = 2; n <= 9; n++) {
    for (int m = 0; m <= n; m++) {
      int t1 = 0;
      if (m - 1 >= 0 && n - 1 >= 0) {
        t1 = minn0[n - 1][m - 1];
      }
      minn[n][m] = 2 * t1 + 7 * minn0[n - 1][m];
    }
  }
}
void caldig(int x) {
  int idx = 0;
  while (x > 0) {
    dig[dignum - idx] = x % 10;
    x = x / 10;
    idx++;
  }
}
int lnum[M];
long long int mod = 1000000000 + 7;
int main() {
  int m;
  cin >> m;
  mluckyinn0();
  mluckyinn();
  int tmp = m;
  while (tmp > 0) {
    dignum++;
    tmp /= 10;
  }
  caldig(m);
  for (int d = 1; d < dignum; d++) {
    for (int j = 0; j <= d; j++) {
      lnum[j] = lnum[j] + minn[d][j];
    }
  }
  int pre = 0;
  int fi = 0;
  for (int i = 1; i <= dignum; i++) {
    int st = 0;
    if (i == 1) {
      st = 1;
    }
    int y47 = 0;
    int n47 = 0;
    for (int j = st; j < dig[i]; j++) {
      if (j == 4 || j == 7) {
        y47++;
      } else {
        n47++;
      }
    }
    int flag = 0;
    if (y47 > 0) {
      flag = 1;
    }
    int ndg = dignum - i;
    for (int j = 0; j <= ndg; j++) {
      lnum[pre + j] = lnum[pre + j] + minn0[ndg][j] * n47;
      lnum[pre + j + flag] = lnum[pre + j + flag] + minn0[ndg][j] * y47;
    }
    if (dig[i] == 4 || dig[i] == 7) {
      pre++;
    }
  }
  lnum[pre]++;
  long long int ans = 0;
  int sta[M];
  for (int i1 = 0; i1 <= 9; i1++) {
    sta[1] = lnum[i1];
    lnum[i1]--;
    for (int i2 = 0; i2 <= 9; i2++) {
      sta[2] = lnum[i2];
      lnum[i2]--;
      for (int i3 = 0; i3 <= 9; i3++) {
        sta[3] = lnum[i3];
        lnum[i3]--;
        for (int i4 = 0; i4 <= 9; i4++) {
          sta[4] = lnum[i4];
          lnum[i4]--;
          for (int i5 = 0; i5 <= 9; i5++) {
            sta[5] = lnum[i5];
            lnum[i5]--;
            for (int i6 = 0; i6 <= 9; i6++) {
              sta[6] = lnum[i6];
              lnum[i6]--;
              int st = i1 + i2 + i3 + i4 + i5 + i6;
              for (int i7 = st + 1; i7 <= 9; i7++) {
                sta[7] = lnum[i7];
                lnum[i7]--;
                long long int val = 1;
                for (int j = 1; j <= 7; j++) {
                  if (sta[j] <= 0) {
                    val = 0;
                    break;
                  } else {
                    val = (val * sta[j]) % mod;
                  }
                }
                ans = (ans + val) % mod;
                lnum[i7]++;
              }
              lnum[i6]++;
            }
            lnum[i5]++;
          }
          lnum[i4]++;
        }
        lnum[i3]++;
      }
      lnum[i2]++;
    }
    lnum[i1]++;
  }
  cout << ans << endl;
  return 0;
}
