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.util.*;
import java.math.*;

public class Main {
    static final long MOD = 1000000007L;
    
    static int[][] dp = new int[10][10];
    
    static {
        dp[0][0] = 1;
        for (int i = 1; i < dp.length; i++) {
            dp[i][0] += 8 * dp[i - 1][0];
            for (int j = 1; j < 10; j++) {
                dp[i][j] += dp[i - 1][j - 1] * 2 + dp[i - 1][j] * 8;
            }
        }
    }
    
    static int[] toArray(int m) {
        int temp = m / 10;
        int c = 1;
        while (temp > 0) {
            temp /= 10;
            c++;
        }
        int[] res = new int[c];
        for (int i = 0; i < c; i++) {
            res[i] = m % 10;
            m /= 10;
        }
        return res;
    }
    
    static void increase(int index, int multi, int shift) {
        for (int i = 0; i + shift < 10; i++) {
            count[i + shift] += multi * dp[index][i];
        }
    }
    
    static long C(int up, int down) {
        if (up < down) {
            return 0;
        }
        long res = 1;
        int c2 = 0;
        int c3 = 0;
        int c5 = 0;
        for (int i = 2; i <= down; i++) {
            int temp = i;
            while (temp % 2 == 0) {
                c2++;
                temp /= 2;
            }
            
            while (temp % 3 == 0) {
                c3++;
                temp /= 3;
            }
            
            
            while (temp % 5 == 0) {
                c5++;
                temp /= 5;
            }
        }
        
        for (int i = up; i > up - down; i--) {
            int temp = i;
            while (temp % 2 == 0 && c2 > 0) {
                c2--;
                temp /= 2;
            }
            while (temp % 3 == 0 && c3 > 0) {
                c3--;
                temp /= 3;
            }
            while (temp % 5 == 0 && c5 > 0) {
                c5--;
                temp /= 5;
            }
            res *= temp;
            res %= MOD;
        }
        return res;
    }
    
    static void search(int index, int left) {
        if (index == 1 && left == 0) {
            int aa = 1;
        }
        
        
        if (left == 0) {
            int require = 0;
            for (int i = 0; i < use.length; i++) {
                require += i * use[i];
            }
            require++;
            if (require < use.length) {
                long base = 1;
                for (int i = 0; i < use.length; i++) {
                    if (use[i] > 0) {
                        base *= C(count[i], use[i]);
                        base %= MOD;
                    }
                }
                base *= 720;
                base %= MOD;
                
                for (int i = require; i < use.length; i++) {
                    if (count[i] == 0) {
                        break;
                    }
                    res += base * count[i];
                    res %= MOD;
                }
            }
            return;
        }
        
        if (index == 9) {
            return;
        }
        
        if (count[index] == 0) {
            return;
        }
        for (int i = 0; i <= left; i++) {
            use[index] = i;
            search(index + 1, left - i);
            use[index] = 0;
        }
    }
    
    static int[] count;
    static int[] use;
    static long res;
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        count = new int[10];
        
        int[] digits = toArray(m);
        int shift = 0;
        for (int i = digits.length - 1; i >= 0; i--) {
            if (digits[i] <= 4) {
                increase(i, digits[i], 0 + shift);
            }
            else if (digits[i] <= 7) {
                increase(i, digits[i] - 1, 0 + shift);
                increase(i, 1, 1 + shift);
            }
            else {
                increase(i, digits[i] - 2, 0 + shift);
                increase(i, 2, 1 + shift);
            }
            if (digits[i] == 4 || digits[i] == 7) {
                shift++;
            }
        }
        count[shift]++;
        count[0]--;
        /*
        int[] check = new int[9];
        for (int i = 1; i <= m; i++) {
            int c = 0;
            int temp = i;
            while (temp > 0) {
                if (temp % 10 == 4 || temp % 10 == 7) {
                    c++;
                }
                temp /= 10;
            }
            check[c]++;
        }
        System.out.println(Arrays.toString(check));
        System.out.println(Arrays.toString(count));
        System.out.println(Arrays.equals(check, count));*/
        /*for (int i = 0; i < 10; i++) {
            System.out.println(count[i] + " ");
        }
        System.out.println();
        */
	res = 0;
        use = new int[10];
        search(0, 6);
        System.out.println(res);
    }
}