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;
template <typename T>
inline T abs(T a) {
  return a < 0 ? (-a) : a;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
int Get10Cnt(long long n) {
  int res = 0;
  while (n) {
    ++res;
    n /= 10;
  }
  return res;
}
const int MAXT = 11;
const long long MOD = 1000000007;
long long tens[MAXT];
long long c[MAXT][MAXT];
long long Pow(long long x, long long y) {
  if (!y) return 1;
  long long p = Pow(x, y >> 1);
  p = (p * p);
  if (y & 1) p = (p * x);
  return p;
}
long long AnsTen(int k, int cnt) {
  if (k < 0 || k > cnt) return 0;
  return c[cnt][k] * Pow(2, k) * Pow(8, cnt - k);
}
long long Rec(int k, long long n) {
  int cnt = Get10Cnt(n);
  if (k < 0 || k > cnt) return 0;
  if (n < 10) {
    if (n < 4) return k == 0 ? n + 1 : k == 1 ? 0 : 0;
    if (n < 7) return k == 0 ? n : k == 1 ? 1 : 0;
    return k == 0 ? n - 1 : k == 1 ? 2 : 0;
  }
  int last = n / tens[cnt - 1];
  int a2 = (last > 4) + (last > 7);
  int a1 = last - a2;
  return a1 * AnsTen(k, cnt - 1) + a2 * AnsTen(k - 1, cnt - 1) +
         Rec(k - (last == 4 || last == 7), n % tens[cnt - 1]);
}
long long GetCCNTX(long long cnt, int x) {
  if (cnt < x) return 0;
  vector<long long> v, r;
  if (x >= 2) v.push_back(2);
  if (x >= 3) v.push_back(3);
  if (x >= 4) {
    v.push_back(2);
    v.push_back(2);
  }
  if (x >= 5) v.push_back(5);
  if (x >= 6) {
    v.push_back(2);
    v.push_back(3);
  }
  for (int i = 0; i < (x); ++i) {
    r.push_back(cnt - i);
  }
  for (int i = 0; i < (r.size()); ++i) {
    for (int j = 0; j < (v.size()); ++j) {
      if (v[j] > 1 && r[i] % v[j] == 0) {
        r[i] /= v[j];
        v[j] = 1;
      }
    }
  }
  for (int j = 0; j < (v.size()); ++j) {
    if (v[j] != 1) exit(1);
  }
  long long res = 1;
  for (int i = 0; i < (r.size()); ++i) {
    res = (res * r[i]) % MOD;
  }
  return res;
}
long long GetBroot(int k, long long n) {
  long long res = 0;
  for (int i = 0; i < (n); ++i) {
    long long a = i + 1;
    int cnt = 0;
    while (a) {
      if (a % 10 == 4 || a % 10 == 7) cnt++;
      a /= 10;
    }
    res += cnt == k;
  }
  return res;
}
int main() {
  tens[0] = 1;
  for (int i = 1; i < MAXT; ++i) {
    tens[i] = tens[i - 1] * 10;
  }
  memset((c), 0, sizeof(c));
  c[0][0] = 1;
  for (int i = 1; i < MAXT; ++i) {
    c[i][0] = 1;
    for (int j = 1; j < MAXT; ++j) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
    }
  }
  long long fact[MAXT];
  fact[0] = 1;
  for (int i = 1; i < MAXT; ++i) {
    fact[i] = fact[i - 1] * i;
  }
  long long n;
  cin >> n;
  long long v[MAXT];
  for (int i = 0; i < (MAXT); ++i) {
    v[i] = Rec(i, n);
  }
  v[0]--;
  long long ans = 0;
  int mi[6];
  int cnt[MAXT];
  for (mi[0] = 0; mi[0] < 10; ++mi[0])
    for (mi[1] = 0; mi[1] < 10; ++mi[1])
      for (mi[2] = 0; mi[2] < 10; ++mi[2])
        for (mi[3] = 0; mi[3] < 10; ++mi[3])
          for (mi[4] = 0; mi[4] < 10; ++mi[4])
            for (mi[5] = 0; mi[5] < 10; ++mi[5]) {
              long long mul = 1;
              long long s = 0;
              memset((cnt), 0, sizeof(cnt));
              for (int i = 0; i < (6); ++i) {
                s += mi[i];
                ++cnt[mi[i]];
              }
              if (s >= 10) continue;
              for (int i = 0; i < (MAXT); ++i) {
                mul = mul * GetCCNTX(v[i], cnt[i]) % MOD * fact[cnt[i]] % MOD;
              }
              for (int i = s + 1; i < 10; ++i) {
                ans += (v[i] * mul) % MOD;
                ans %= MOD;
              }
            }
  cout << ans << endl;
  return 0;
}