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.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;


public class D {
	int MODULAR = 1000000007;
	int M;
	long[] numcount;
	public void solve(){
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));		
		Scanner sc = new Scanner(System.in);
		M = sc.nextInt();
				
//		int[] ct = count(M);
		
//		for(int i = 1; i <= Math.min(M, 9); i++){
//			if( i == 4 || i == 7) bfs(i, 1);
//			else bfs(i, 0);
//		}
		numcount = count(M);
				
//		for(int i = 0; i <= 9; i++){								
//			System.out.println(i + ": " + numcount[i]);
//		}
//		
//		for(int i = 0; i <= 9; i++){
//			System.out.println(i + ": " + ct[i] );			
//		}
		
		long ans = 0;
		for(int i = 1; i <= 9; i++){
			for(int x1 = 0; x1 < i; x1++){
				for(int x2 = 0; x1+x2 < i; x2++){
					for(int x3 = 0; x1+x2+x3 < i; x3++){
						for(int x4 = 0; x1+x2+x3+x4 < i; x4++){
							for(int x5 = 0; x1+x2+x3+x4+x5 < i; x5++){
								for(int x6 = 0; x1+x2+x3+x4+x5+x6 < i; x6++){
//									System.out.println("-->" + i + ", " + x1 + ", " + x2 + ", " + x3 + ", " + x4 + ", " + x5 + ", " + x6);
									int[] a = new int[10];
									a[x1]++;
									a[x2]++;
									a[x3]++;
									a[x4]++;
									a[x5]++;
									a[x6]++;
									long tmp = numcount[i];
									for(int j = 0; j <= 9; j++){
										for(int k = 0; k < a[j]; k++){
											tmp = tmp * (numcount[j]-k) % MODULAR;
										}
									}
									ans += tmp;									
								}
							}
						}
					}
				}
			}					
		}
		ans = ans % MODULAR;
		System.out.println( ans );
	}
		
	public void bfs(long num, int count){
		numcount[count]++;
		for(int i = 0; i <= 9; i++){
			if( num*10+i > M) break;
			if( i == 4 || i == 7) bfs( num*10+i, count+1);
			else bfs( num*10+i, count);
		}
	}
	
	
	long[] count(long m)
	{
		int[][] dp = new int[11][11];
		dp[0][0] = 1;
		
		int e = 0;
		long d = 1;
		for(;d <= m;d *= 10,e++){
			for(int i = 10;i >= 0;i--){
				dp[e+1][i] = dp[e][i]*8+(i-1 >= 0 ? dp[e][i-1]*2 : 0);
			}
		}
		
		long[] ret = new long[11];
		int edge = 0;
		for(;e >= 0;d /= 10,e--){
			int q = (int)(m/d%10);
			for(int i = 0;i < q;i++){
				if(i == 4 || i == 7){
					for(int k = 0;k <= 10 && edge+1+k <= 10;k++){
						ret[edge+1+k] += dp[e][k];
					}
				}else{
					for(int k = 0;k <= 10 && edge+k <= 10;k++){
						ret[edge+k] += dp[e][k];
					}
				}
			}
			if(q == 4 || q == 7)edge++;
		}
		ret[edge]++;
		ret[0]--;
		
		return ret;
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new D().solve();
	}

}