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 LL = 0;
long long LuckyNums[2001];
long long totalnums;
long long mycontainer[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
long long Digitizor[10];
long long MDIG[10];
long long breaker[10001][7];
long long bL;
long long tempfill[7];
long long local[7];
long long guysgot[10];
const long long MOD = 1000000007;
void Generator(long long leftdigs, long long num) {
  if (leftdigs == 0) {
    LL++;
    LuckyNums[LL] = num;
    return;
  } else {
    Generator(leftdigs - 1, num * 10 + 4);
    Generator(leftdigs - 1, num * 10 + 7);
  }
}
long long Digs(long long k) {
  long long ctr = 0;
  if (k == 0) return 1;
  while (k > 0) {
    ctr++;
    k = k / 10;
  }
  return ctr;
}
void GetNums(long long luckers, long long mustuse, bool smaller,
             long long waystogethere, long long leftdigs, long long digfill) {
  long long x, i;
  long long smallershit = 0;
  if (waystogethere == 0) return;
  if (leftdigs == 0) {
    mycontainer[luckers] += waystogethere;
    return;
  }
  if (leftdigs - (luckers - mustuse + 1) < 0) {
    return;
  }
  if (mustuse <= luckers && leftdigs - (luckers - mustuse + 1) == 0) {
    if (smaller)
      GetNums(luckers, mustuse + 1, true, waystogethere, leftdigs - 1,
              digfill + 1);
    else {
      if (Digitizor[mustuse] < MDIG[digfill]) {
        GetNums(luckers, mustuse + 1, true, waystogethere, leftdigs - 1,
                digfill + 1);
      } else if (Digitizor[mustuse] == MDIG[digfill]) {
        GetNums(luckers, mustuse + 1, false, waystogethere, leftdigs - 1,
                digfill + 1);
      }
    }
    return;
  }
  if (mustuse <= luckers) {
    if (smaller)
      GetNums(luckers, mustuse + 1, true, waystogethere, leftdigs - 1,
              digfill + 1);
    else {
      if (Digitizor[mustuse] < MDIG[digfill]) {
        GetNums(luckers, mustuse + 1, true, waystogethere, leftdigs - 1,
                digfill + 1);
      } else if (Digitizor[mustuse] == MDIG[digfill]) {
        GetNums(luckers, mustuse + 1, false, waystogethere, leftdigs - 1,
                digfill + 1);
      }
    }
  }
  if (smaller) {
    if (totalnums == leftdigs)
      x = 7;
    else
      x = 8;
    GetNums(luckers, mustuse, true, waystogethere * x, leftdigs - 1,
            digfill = 1);
  } else {
    if (totalnums == leftdigs)
      x = 1;
    else
      x = 0;
    smallershit = 0;
    for (i = x; i <= 9; i++) {
      if (i == 7 || i == 4) continue;
      if (MDIG[digfill] > i) {
        smallershit++;
      } else if (MDIG[digfill] == i) {
        GetNums(luckers, mustuse, false, waystogethere, leftdigs - 1,
                digfill + 1);
      } else
        break;
    }
    GetNums(luckers, mustuse, true, waystogethere * smallershit, leftdigs - 1,
            digfill + 1);
  }
  return;
}
void BrakeNum(long long barrier, long long cursum, long long leftdigs,
              long long filldig, long long lastnum) {
  long long i;
  if (leftdigs == 0) {
    bL++;
    for (i = 1; i <= 6; i++) {
      breaker[bL][i] = tempfill[i];
    }
    return;
  }
  for (i = lastnum; i <= 9; i++) {
    if (cursum + i < barrier) {
      tempfill[filldig] = i;
      BrakeNum(barrier, cursum + i, leftdigs - 1, filldig + 1, i);
    }
  }
}
int main() {
  long long i, j, in, ja;
  long long m;
  long long copy;
  long long thisone;
  long long total = 0;
  bool wasmax;
  scanf("%I64d", &m);
  if (m == 1000000000) {
    wasmax = true;
    m--;
  } else
    wasmax = false;
  copy = m;
  for (i = Digs(m); i >= 1; i--) {
    MDIG[i] = copy % 10;
    copy = copy / 10;
  }
  for (i = 1; i <= 9; i++) {
    Generator(i, 0);
  }
  for (i = 1; i <= LL; i++) {
    if (Digs(LuckyNums[i]) == 9 && LuckyNums[i] <= m) {
      mycontainer[9]++;
    }
  }
  for (i = 1; i <= LL; i++) {
    if (Digs(LuckyNums[i]) == 9) continue;
    copy = LuckyNums[i];
    for (j = Digs(LuckyNums[i]); j >= 1; j--) {
      Digitizor[j] = copy % 10;
      copy = copy / 10;
    }
    for (j = Digs(LuckyNums[i]); j <= Digs(m); j++) {
      totalnums = j;
      if (j == Digs(m))
        GetNums(Digs(LuckyNums[i]), 1, false, 1, j, 1);
      else
        GetNums(Digs(LuckyNums[i]), 1, true, 1, j, 1);
    }
  }
  for (i = 1; i <= Digs(m); i++) {
    totalnums = i;
    if (i == Digs(m))
      GetNums(0, 1, false, 1, i, 1);
    else
      GetNums(0, 1, true, 1, i, 1);
  }
  if (wasmax) mycontainer[0]++;
  for (i = 1; i <= 9; i++) {
    if (mycontainer[i] == 0) continue;
    bL = 0;
    BrakeNum(i, 0, 6, 1, 0);
    for (j = 1; j <= bL; j++) {
      for (in = 1; in <= 6; in++) {
        local[in] = breaker[j][in];
      }
      sort(local + 1, local + 7);
      do {
        for (in = 0; in <= 9; in++) {
          guysgot[in] = 0;
        }
        for (in = 1; in <= 6; in++) {
          guysgot[local[in]]++;
        }
        thisone = 1;
        for (in = 0; in <= 9; in++) {
          for (ja = mycontainer[in]; ja >= mycontainer[in] - guysgot[in] + 1;
               ja--) {
            thisone = (thisone * (ja % MOD)) % MOD;
          }
        }
        thisone = (thisone * (mycontainer[i] % MOD)) % MOD;
        total = (total + thisone) % MOD;
      } while (next_permutation(local + 1, local + 7));
    }
  }
  printf("%I64d\n", total);
  return 0;
}