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.Scanner;

public class Main {
    static int[] d = new int[11];
    static int[] N = new int[11];
    static int[] L = new int[11];
    static long[][][] f;
    static int[] matrix = new int[11];
    static long[] c;
    public static long nPr(long n,long r){
        if(n<r)return 0;
        long answer = 1;
        for(long i=n;i>=n-r+1;i--){
            answer = (answer*i)%1000000007;
        }
        return answer;
    }
    public static void build(long x){
        int nDigits = 0;
        long tmp = x;
        while(tmp!=0){
            tmp/=10;
            nDigits++;
        }
        long mem = 0;
        for(int i=0;i<nDigits;i++){
            d[i+1] = (int) ((x / Math.pow(10, nDigits-1-i)) - mem);
            mem = (mem+d[i+1])*10;
        }
        N[0] = 0;
        L[0] = 0;
        for(int i=1;i<10;i++){
            L[i] = L[i-1] + (i-1==7 || i-1==4?1:0);
            N[i] = N[i-1] + (i-1!=7 && i-1!=4?1:0);
        }
        for(int i=1;i<nDigits+1;i++){
            matrix[i] = matrix[i-1] + ((d[i]==7 || d[i]==4)?1:0);
        }
        //for(int i=0;i<matrix.length;i++)System.out.println(matrix[i]);
        f = new long[nDigits+1][nDigits+1][2];
        f[1][0][0] = N[d[1]];
        f[1][1][0] = L[d[1]];
        f[1][0][1] = (d[1] == 4 || d[1] == 7)?0:1;
        f[1][1][1] = (d[1] == 4 || d[1] == 7)?1:0;
        for(int i=2;i<nDigits+1;i++){
            f[i][0][1] = (matrix[i] == 0?1:0);
            f[i][0][0] = (  8*f[i-1][0][0] + N[d[i]]*f[i-1][0][1]  )%1000000007;
            for(int j=1;j<=i;j++){
                f[i][j][1] = matrix[i] == j?1:0;
                f[i][j][0] = (  (8*f[i-1][j][0]) + (N[d[i]]*f[i-1][j][1]) + 
                        (2*f[i-1][j-1][0]) + (L[d[i]]*f[i-1][j-1][1])  )%1000000007;
            }
        }
        c = new long[nDigits+1];
        for(int i=0;i<nDigits+1;i++){
            c[i] = (f[nDigits][i][0] + f[nDigits][i][1]) %1000000007;
        }
        c[0]--;
        
    }
    public static int[] copy(int[] arr){
        int[] newArr = new int[arr.length]; 
        for(int i=0;i<arr.length;i++)newArr[i] = arr[i];
        return newArr;
    }
    static long globalSum = 0;
    public static void count(int current,int max,int[] groups){
        if(current == 6){
            long sum = 1;
            for(int i=0;i<groups.length;i++){
                sum = (sum * nPr(c[i],groups[i])) % 1000000007;
            }
            globalSum = (globalSum  + sum) %1000000007;
            return;
        }
        else{
            for(int i=0;i<=max;i++){
                int[] newGroups = copy(groups);
                newGroups[i]++;
                count(current+1,max==0?max:max-i,newGroups);
            }
        }
    }
    public static long solve(){
        long sum = 0;
        for(int i=1;i<c.length;i++){
            int[] groups = new int[i];
            //System.out.println("Elephant: " + i);
            count(0,i-1,groups);
            sum = (sum + (c[i]*globalSum)) % 1000000007;
            globalSum = 0;
        }
        
        return sum;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long m = sc.nextLong();
        build(m);
        //for(int i=0;i<N.length;i++)System.out.println(N[i]);
        System.out.println(solve());
    }
}