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;
int DEBUG = 0;
int Min(int a, int b) { return (a < b ? a : b); }
int Max(int a, int b) { return (a > b ? a : b); }
int Abs(int a) { return (a >= 0 ? a : -a); }
void print1d(int *vec, int M, const char *str = NULL) {
  if (str != NULL) printf("%s ", str);
  for (int i = 0; i < M; i++) {
    if (i > 0) printf(" ");
    printf("%d", vec[i]);
  }
  printf("\n");
}
int64_t pascal[11][11];
int64_t ipow(int64_t a, int64_t p) {
  int64_t out = 1;
  for (int64_t i = 1; i <= p; i++) out *= a;
  return out;
}
void update_freq(char *str, int64_t *freq) {
  int n = strlen(str);
  if (n == 0) return;
  for (char c = '0'; c < str[0] || (n == 1 && c <= str[0]); c++) {
    if (c == '4' || c == '7') {
      for (int j = 0; j <= (n - 1); j++) {
        freq[j + 1] += pascal[n - 1][j] * ipow(2, j) * ipow(8, n - 1 - j);
      }
    } else {
      for (int j = 0; j <= (n - 1); j++) {
        freq[j] += pascal[n - 1][j] * ipow(2, j) * ipow(8, n - 1 - j);
      }
    }
    if (DEBUG) {
      cout << "c= " << c << " n= " << n << " str= " << str << ":";
      for (int i = 0; i <= n; i++) {
        cout << " f[" << i << "]= " << freq[i];
      }
      cout << endl;
    }
  }
  if (n > 1) {
    int64_t freqnext[11];
    for (int i = 0; i < 11; i++) freqnext[i] = 0;
    update_freq(str + 1, freqnext);
    if (str[0] == '4' || str[0] == '7') {
      for (int i = n - 1; i >= 0; i--) freqnext[i + 1] = freqnext[i];
      freqnext[0] = 0;
    }
    for (int i = 0; i <= n; i++) {
      freq[i] += freqnext[i];
    }
  }
  if (DEBUG) {
    cout << "n= " << n << " str= " << str << ":";
    for (int i = 0; i <= n; i++) {
      cout << " f[" << i << "]= " << freq[i];
    }
    cout << endl;
  }
}
int main(int argc, char **argv) {
  DEBUG = (argc >= 2) ? atoi(argv[1]) : 0;
  pascal[0][0] = 1;
  for (int n = 1; n <= 10; n++) {
    pascal[n][0] = pascal[n][n] = 1;
    for (int p = 1; p <= n - 1; p++) {
      pascal[n][p] = (pascal[n - 1][p - 1] + pascal[n - 1][p]);
    }
  }
  char raw[20];
  cin >> raw;
  int64_t freq[11];
  for (int i = 0; i < 11; i++) freq[i] = 0;
  int n = strlen(raw);
  update_freq(raw, freq);
  freq[0]--;
  int64_t out = 0;
  for (int i = 1; i <= n; i++) {
    for (int j1 = 0; j1 < i; j1++) {
      for (int j2 = 0; j2 < i - j1; j2++) {
        for (int j3 = 0; j3 < i - j1 - j2; j3++) {
          for (int j4 = 0; j4 < i - j1 - j2 - j3; j4++) {
            for (int j5 = 0; j5 < i - j1 - j2 - j3 - j4; j5++) {
              for (int j6 = 0; j6 < i - j1 - j2 - j3 - j4 - j5; j6++) {
                int64_t out2 = 1;
                out2 = (out2 * freq[i]) % 1000000007;
                freq[i]--;
                out2 = (out2 * freq[j1]) % 1000000007;
                freq[j1]--;
                out2 = (out2 * freq[j2]) % 1000000007;
                freq[j2]--;
                out2 = (out2 * freq[j3]) % 1000000007;
                freq[j3]--;
                out2 = (out2 * freq[j4]) % 1000000007;
                freq[j4]--;
                out2 = (out2 * freq[j5]) % 1000000007;
                freq[j5]--;
                out2 = (out2 * freq[j6]) % 1000000007;
                freq[j5]++;
                freq[j4]++;
                freq[j3]++;
                freq[j2]++;
                freq[j1]++;
                freq[i]++;
                out = (out + out2) % 1000000007;
              }
            }
          }
        }
      }
    }
  }
  cout << out << endl;
  return 0;
}