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.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class B{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m;
	int d=11;

	int mod=(int)1e9+7;

	void run(){
		m=sc.nextInt();
		solve();
	}

	int[] a;

	void solve(){
		m++;
		a=new int[d];
		for(int i=0, n=m; i<d; i++, n/=10){
			a[i]=n%10;
		}

		int[] c=new int[d];
		c[4]=c[7]=1;

		long[][][] count=new long[d][d][d];
		// count[j][i] : [0, i*10^j)のカウント
		count[0][5][1]=count[0][6][1]=count[0][7][1]=1;
		count[0][8][1]=count[0][9][1]=count[0][10][1]=2;
		for(int j=0; j<d; j++){
			if(j>0){
				for(int k=0; k<d; k++){
					count[j][1][k]+=count[j-1][10][k];
				}
				// debug(j);
				// debug(1, count[j][1]);
				for(int i=2; i<d; i++){
					for(int k=0; k<d; k++){
						count[j][i][k]+=count[j][i-1][k];
						if(k+c[i-1]<d){
							count[j][i][k+c[i-1]]+=count[j][1][k];
						}
					}
					// debug(i, count[j][i]);
				}
			}
			for(int i=0; i<d; i++){
				count[j][i][0]=(long)pow(10, j)*i;
				for(int k=1; k<10; k++){
					count[j][i][0]-=count[j][i][k];
				}
			}
		}

		int[] hoge=new int[d];
		if(false)
			for(int i=1; i<m; i++){
				hoge[lucky(i)]++;
			}

		memo=new long[d];
		// debug(a);
		int sum=0;
		for(int i=0; i<d; i++){
			sum+=c[a[i]];
		}
		for(int j=0, n=m; j<d; j++, n/=10){
			sum-=c[a[j]];
			// debug(j, n%10, count[j][n%10]);
			for(int k=0; k<d; k++){
				if(sum+k<d){
					memo[sum+k]+=count[j][n%10][k];
				}
			}
		}
		memo[0]--;
//		debug("memo", memo);
//		debug("hoge", hoge);
		// println(String.format("%d", dfs(0, 0, 0)%mod));
		println(dfs(0, 0, 0)+"");
	}

	int lucky(int n){
		int res=0;
		for(; n!=0; n/=10){
			if(n%10==4||n%10==7){
				res++;
			}
		}
		return res;
	}

	long[] memo;

	long dfs(int index, int me, int sum){
		// debug(index, me, sum);
		if(index==7){
			if(me>sum){
				return 1;
			}else{
				return 0;
			}
		}
		long res=0;
		if(index==0){
			for(int i=0; i<d; i++){
				if(memo[i]>0){
					long m=memo[i]%mod;
					memo[i]--;
					res=(res+m*dfs(index+1, i, 0)%mod)%mod;
					memo[i]++;
				}
			}
		}else{
			for(int i=0; i<d; i++){
				if(memo[i]>0){
					long m=memo[i]%mod;
					memo[i]--;
					res=(res+m*dfs(index+1, me, sum+i)%mod)%mod;
					memo[i]++;
				}
			}
		}
		return res;
	}

	void println(String s){
		System.out.println(s);
	}

	void print(String s){
		System.out.print(s);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new B().run();
	}
}