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;
long long mod = 1000000007;
long long dat[11];
long long dp[11][11][2];
void calc(int num) {
  vector<int> vec;
  for (;;) {
    if (num == 0) {
      break;
    }
    vec.push_back(num % 10);
    num /= 10;
  }
  reverse(vec.begin(), vec.end());
  dp[0][0][0] = 1;
  for (int i = 1; i <= vec.size(); i++) {
    for (int j = 0; j <= vec.size(); j++) {
      dp[i][j][1] += dp[i - 1][j][1] * 8;
      if (j != 0) {
        dp[i][j][1] += dp[i - 1][j - 1][1] * 2;
      }
      for (int k = 0; k < 10; k++) {
        if (vec[i - 1] > k) {
          if (k == 4 || k == 7) {
            dp[i][j][1] += dp[i - 1][j - 1][0];
          } else {
            dp[i][j][1] += dp[i - 1][j][0];
          }
        }
        if (vec[i - 1] == k) {
          if (k == 4 || k == 7) {
            dp[i][j][0] += dp[i - 1][j - 1][0];
          } else {
            dp[i][j][0] += dp[i - 1][j][0];
          }
        }
      }
    }
  }
  for (int i = 0; i <= vec.size(); i++) {
    dat[i] = dp[vec.size()][i][0] + dp[vec.size()][i][1];
  }
  dat[0]--;
}
long long po(long long a, long long b) {
  vector<int> vec;
  for (;;) {
    if (b == 0) {
      break;
    }
    vec.push_back(b % 2);
    b /= 2;
  }
  reverse(vec.begin(), vec.end());
  long long ret = 1;
  for (int i = 0; i < vec.size(); i++) {
    ret *= ret;
    ret %= mod;
    if (vec[i]) {
      ret *= a;
      ret %= mod;
    }
  }
  return ret;
}
long long inv(long long a) { return po(a, mod - 2); }
long long kai[100001];
void calckai() {
  kai[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    kai[i] = kai[i - 1] * i;
    kai[i] %= mod;
  }
}
long long com(long long a, long long b) {
  long long ret = kai[a];
  ret *= inv(kai[b]);
  ret %= mod;
  ret *= inv(kai[a - b]);
  ret %= mod;
  return ret;
}
long long ans = 0;
void calcans(vector<int> vec, long long tim) {
  long long ret = 1;
  long long tim2 = 1;
  long long rem = 6;
  for (int i = 0; i < vec.size(); i++) {
    for (int j = 1; j <= vec[i]; j++) {
      ret *= (dat[i] - j + 1);
      ret %= mod;
    }
    if (vec[i] != 0) {
      tim2 *= com(rem, vec[i]);
      tim2 %= mod;
      rem -= vec[i];
    }
  }
  ret *= tim2;
  ret %= mod;
  ans += (ret * tim) % mod;
  ans %= mod;
}
void solve(int nowsum, int now, int mok, vector<int> vec, long long tim,
           int gou) {
  if (nowsum >= mok || gou > 6) {
    return;
  }
  if (now == 10 && gou == 6) {
    calcans(vec, tim);
    return;
  }
  if (now == 10 && gou != 6) {
    return;
  }
  for (int i = 0; i <= min(6LL, dat[now]); i++) {
    vec.push_back(i);
    solve(nowsum + i * now, now + 1, mok, vec, tim, gou + i);
    vec.pop_back();
  }
}
int main() {
  int num;
  scanf("%d", &num);
  calc(num);
  calckai();
  for (int i = 1; i <= 9; i++) {
    if (dat[i] == 0) {
      continue;
    }
    dat[i]--;
    vector<int> damy;
    solve(0, 0, i, damy, dat[i] + 1, 0);
    dat[i]++;
  }
  printf("%I64d\n", ans);
}