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


public class Main {
   
    static BufferedReader in; 
    
    public static void main(String[] args) throws IOException{        
        File file = new File("input.txt");
        if( file.exists() ) in = new BufferedReader(new FileReader(file));
        else in = new BufferedReader(new InputStreamReader(System.in));
        
        final long MOD=1000000007;
        long ans=0;
        int digit[]=new int[10];
        String m=in.readLine();
        for(int i=0; i<m.length(); i++) digit[i]=m.charAt(i)-'0';
                
        long dp[][][]=new long[11][11][3];
        dp[0][0][0] = dp[0][0][1] = 1;
        for(int i=1; i<=m.length(); i++){
            for(int j=0; j<=m.length(); j++){
                for(int cmp=-1; cmp<=1; cmp++){
                    int nCmp;
                    for(int d=0; d<10; d++){
                        if(cmp==0){
                            if(d==digit[i-1]) nCmp=0;
                            else nCmp=(d-digit[i-1])/Math.abs(d-digit[i-1]);
                        } else if( d<digit[i-1] ) nCmp=-1;
                        else if( d>digit[i-1] ) nCmp=1;
                        else nCmp=cmp;
                        if( (d==4||d==7) ){
                                if(j>0) dp[i][j][cmp+1]+=dp[i-1][j-1][nCmp+1];
                        } else dp[i][j][cmp+1]+=dp[i-1][j][nCmp+1];
                    }
                }
            }    
        }
        
        long cnt[]=new long[m.length()+1];
        for(int i=0; i<=m.length(); i++) {
            cnt[i] = dp[m.length()][i][0+1];
        }
        cnt[0]--; // element zero
        for(int a=0; a<=m.length(); a++)
        for(int b=0; b<=m.length(); b++)
        for(int c=0; c<=m.length(); c++)
        for(int d=0; d<=m.length(); d++)
        for(int e=0; e<=m.length(); e++)
        for(int f=0; f<=m.length(); f++){
            boolean can=true;
            int tot[]=new int[m.length()+1];
            for(int i=0; can && i<=m.length(); i++){
                if(a==i)tot[i]++;
                if(b==i)tot[i]++;
                if(c==i)tot[i]++;
                if(d==i)tot[i]++;
                if(e==i)tot[i]++;
                if(f==i)tot[i]++;
                if(tot[i]>cnt[i]) can=false;
            }      
            if(!can) continue;
            int sum=a+b+c+d+e+f;
            long ways=1;
            for(int i=0; i<=m.length(); i++){
                for(int j=tot[i]-1; j>=0; j--){
                    ways = ways*(cnt[i]-j)%MOD;
                }
            }
            for(int i=0; i<=m.length(); i++){
                if(tot[i]<cnt[i] && sum<i) 
                    ans = (ans + (ways*cnt[i]%MOD) )%MOD;
            }
        }
        System.out.println(ans);
    }
    
    static void out(Object ...o){ System.out.println(Arrays.deepToString(o)); }    
    
    static String[] readToks() throws IOException{
        return in.readLine().split("[ ]+");
    }
    
    static int readInt() throws IOException{
        return Integer.parseInt(in.readLine());
    }
    
    static long readLong() throws IOException{
        return Long.parseLong(in.readLine());
    }
       
    static int[] readNums(int n) throws IOException{
        int[] nums = new int[n];
	int idx = 0;
	String line = in.readLine().trim();
	for(int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
		if(c == ' ') idx++;
		else {
                    int d = c - '0';
                    nums[idx] = 10 * nums[idx] + d;
		}
	}
		
	return nums;
    }
	
    static int[] readNums() throws IOException {		
        int idx = 0, n = 0;		
        String line = in.readLine().trim();
	int i;
	for(i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if(c == ' ') break;
            int d = c - '0';
            n = 10 * n + d;
        }
		
	int[] nums = new int[n];
	for(i = i + 1; i < line.length(); i++) {
            char c = line.charAt(i);
            if(c == ' ') idx++;
            else {
                int d = c - '0';
                nums[idx] = 10 * nums[idx] + d;
            }
        }
	return nums;
    }
}