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 JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.util.*;

public class B {
    public static void main(String[] args) throws Exception {
        new B().solve(System.in, System.out);
        // new FileInputStream(new File("input.txt")),
        // new PrintStream(new FileOutputStream(new File("output.txt"))));
    }


    long mod;
    int mlen;
    int[] nlclte;
    void solve(InputStream _in, PrintStream out) throws IOException {
        // BufferedReader in = new BufferedReader(new InputStreamReader(_in));
        // String[] sp;
        Scanner sc = new Scanner(_in);
        mod = 1000000007;

        int m = sc.nextInt();

        int[] mar = new int[20];
        mlen = 0;
        while (m > 0) {
            mar[mlen++] = m % 10;
            m /= 10;
        }

        int[][][] dp = new int[mlen + 1][mlen + 1][2];

        // len=1
        dp[1][0][0] = 8;
        dp[1][0][1] = (mar[0] >= 7 ? mar[0] - 2 : (mar[0] >= 4 ? mar[0] - 1 : mar[0])) + 1;
        dp[1][1][0] = 2;
        dp[1][1][1] = mar[0] >= 7 ? 2 : (mar[0] >= 4 ? 1 : 0);
        for (int len = 2; len <= mlen; len++) {
            for (int lc = 0; lc <= len; lc++) {
                for (int d = 0; d < 10; d++) {

                    if (d == 4 || d == 7) {
                        if (lc > 0) {
                            // 0
                            dp[len][lc][0] += dp[len - 1][lc - 1][0];

                            // 1
                            if (d < mar[len - 1]) {
                                dp[len][lc][1] += dp[len - 1][lc - 1][0];
                            } else if (d == mar[len - 1]) {
                                dp[len][lc][1] += dp[len - 1][lc - 1][1];
                            }
                        }

                    } else {// d!=4,7
                        // 0
                        dp[len][lc][0] += dp[len - 1][lc][0];

                        // 1
                        if (d < mar[len - 1]) {
                            dp[len][lc][1] += dp[len - 1][lc][0];
                        } else if (d == mar[len - 1]) {
                            dp[len][lc][1] += dp[len - 1][lc][1];
                        }
                    }
                }
            }
        }

        nlclte = new int[mlen + 1];
        for (int lc = 0; lc <= mlen; lc++) {
            nlclte[lc] = dp[mlen][lc][1];
            if (lc > 0) {
                nlclte[lc] += nlclte[lc - 1];
            }
            if (lc == 0) {
                nlclte[lc] -= 1;
            }
        }
        use = new int[mlen + 1];
        System.out.println(dfs(0, 0));
    }

    int[] use;
    long dfs(int count, int sum) {
        if (count < 6) {
            long ret = 0;
            for (int i = 0; i + sum < mlen; i++) {
                if (use[i] + 1 <= nlclte[i]) {
                    use[i]++;
                    long nlc = i == 0 ? nlclte[0] : nlclte[i] - nlclte[i - 1];
                    ret += (nlc - use[i] + 1) * dfs(count + 1, sum + i);
                    ret %= mod;
                    use[i]--;
                } else {
                    // continue
                }
            }
            return ret % mod;
        } else {// idx==6
            // mlen>sum
            return nlclte[mlen] - nlclte[sum];
        }
    }
}

//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//