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:
//package codeforces.cf157;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ProblemB {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    int[] readInts() throws IOException {
        String[] strings = reader.readLine().split(" ");
        int[] ints = new int[strings.length];
        for(int i = 0; i < ints.length; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        return ints;
    }

    void solve() throws IOException {
        int m = readInts()[0];
        int[] count = new int[10];
        long[] pow10 = new long[12];
        pow10[0] = 1;
        for(int i = 1; i < 12; i++) pow10[i] = pow10[i - 1] * 10;

        int[][] C = new int[15][15];
        for(int n = 0; n < 15; n++) {
            C[n][0] = 1;
            for(int k = 1; k <= n; k++) {
                C[n][k] = C[n - 1][k] + C[n - 1][k - 1];
            }
        }

        for(int len = 1; pow10[len] <= m; len++) {
            for(int k = 1; k <= len; k++) {
                //starts with 4 or 7
                count[k] += (1 << k) * (1 << 3 * (len - k)) * C[len - 1][k - 1];
                //not
                count[k] += (1 << k) * 7 * (1 << 3 * (len - k - 1)) * C[len - 1][k];
            }
        }
        List<Integer> digits = new ArrayList<Integer>();
        int x = m;
        while(x > 0) {
            digits.add(x % 10);
            x /= 10;
        }
        Integer[] a = new Integer[digits.size()];
        Collections.reverse(digits);
        digits.toArray(a);
        int lucky = 0;
        for(int i = 0; i < a.length; i++) {
            for(int d = 0; d < a[i]; d++) {
                if(d == 0 && i == 0) continue;
                int luck = d == 4 || d == 7 ? 1 : 0;
                int len = a.length - i - 1;
                for(int k = 0; k <= len; k++) {
                    count[k + lucky + luck] += (1 << k) * (1 << 3 * (len - k)) * C[len][k];
                }
            }
            if(a[i] == 4 || a[i] == 7) lucky++;
        }
        count[lucky]++;
        count[0] = m;
        for(int i = 1; i < 10; i++) count[0] -= count[i];

        int[][][] dp = new int[7][11][11];
        for(int i = 0; i < 11; i++) {
            dp[0][0][i] = 1;
        }
        for(int left = 1; left <= 6; left++) {
            for(int cnt = 0; cnt < 10; cnt++) {
                for(int k = 0; k < 10; k++) {
                    ////////
                    for(int i = k; i < 10; i++) {
                        for(int use = 1; use <= left; use++) {
                            if(use * i > cnt) break;
                            int mul = 1;
                            for(int j = 0; j < use; j++) {
                               // mul *= count[i] - j;
                                mul = mult(mul, count[i] - j);
                            }
                            //dp[left][cnt][k] += mul * dp[left - use][cnt - use * i][i + 1];
                            dp[left][cnt][k] = sum(dp[left][cnt][k], mult(C[left][use], mult(mul, dp[left - use][cnt - use * i][i + 1])));
                        }
                    }
                }
            }
        }
        int ans = 0;
        for(int i = 1; i < 10; i++) {
            for(int j = 0; j < i; j++) {
                ans = sum(ans, mult(count[i], dp[6][j][0]));
            }
        }
        writer.println(ans);
        writer.flush();
    }

    static final int MOD = 1000 * 1000 * 1000 + 7;

    int mult(int a, int b) {
        return (int)((long)a * b % MOD);
    }
    int sum(int a, int b) {
        a += b;
        if(a >= MOD) return a - MOD;
        return a;
    }

    public static void main(String[] args) throws IOException{
        new ProblemB().solve();
    }
}