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

public class Round157B {
	public static void main(String[] args) throws IOException {
		rd = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
		M = Integer.parseInt(rd.readLine());
		for(int i=0; i<C.length; i++) C[i][0] = 1;
		for(int i=1; i<C.length; i++) for(int j=1; j<=i; j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%P;
		p2[0] = p8[0] = 1;
		for(int i=1; i<20; i++){
			p2[i] = (p2[i-1] * 2)%P;
			p8[i] = (p8[i-1] * 8)%P;
		}
		countNArray();
		long ans = 0;
		for(int NL=0; NL<=9; NL++){
			for(int x1=0; x1<=9; x1++){
				for(int x2=0; x2<=9; x2++){
					for(int x3=0; x3<=9; x3++){
						for(int x4=0; x4<=9; x4++){
							for(int x5=0; x5<=9; x5++){
								for(int x6=0; x6<=Math.min(9, NL-x1-x2-x3-x4-x5-1); x6++){
									ans += countFor(NL, x1, x2, x3, x4, x5, x6);
									if(ans>P) ans -= P;
								}
							}
						}
					}
				}
			}
		}
		pw.println(ans);
		pw.flush();
	}
	
	static long[][] C = new long[20][20];
	
	static long[] p2 = new long[20], p8 = new long[20];
	
	static long A(int X, int y){
		long res = 1;
		for(long i=X; i>=X-y+1; i--) res = (res * i)%P;
		return res;
	}
	
	
	
	static long countFor(int NL, int x1, int x2, int x3, int x4, int x5, int x6){
		int[] a = new int[10];
	//	System.out.println(" here with "+x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6);
		a[x1]++;
		a[x2]++;
		a[x3]++;
		a[x4]++;
		a[x5]++;
		a[x6]++;
		a[NL]++;
		long res = 1;
		for(int i=0; i<10; i++){
			if(a[i]>0)
				res = (res * A(N[i], a[i]))%P;
		}
	//	System.out.println("result = "+res);
		return res;
	}
	
	static int[] N1 = new int[10];
	
	static void naiveCount(){
		for(int i=1; i<=M; i++){
			int numL = numLuckyIn(i);
			N1[numL]++;
		}
	}
	
	static void countNArray(){
		if(M<1000000){
			for(int i=1; i<=M; i++){
				int numL = numLuckyIn(i);
				N[numL]++;
			}
			return;
		}
		L = (""+M).length();
		int pow = 1;
		for(int i=0; i<L-5; i++) pow *= 10;
		int[][] A = new int[1+pow][10];
		T = new int[pow+1][10];
		for(int num=0; num<pow; num++){
			int NL = numLuckyIn(num);
			A[num][NL]++;
		}
		for(int NL=0; NL<=9; NL++) T[0][NL] = A[0][NL];
		for(int i=1; i<T.length; i++)
			for(int NL=0; NL<=9; NL++)
				T[i][NL] = T[i-1][NL] + A[i][NL];
		for(int i=0; i<=9; i++) countFor(i);
	}
	
	static void countFor(int K){ // count N[K]
		long r = 0;
		for(int i=1; i<L; i++){
			if(i<K) continue;
			if(K!=0) r += (C[i-1][K-1]*p2[K]*p8[i-K] + ((i!=K)? C[i-1][K]*p2[K]*7*p8[i-1-K] : 0));
			else if(i>0) r += p2[K]*p8[i-K-1]*7;
		}
		r = (r+countSameLengthFor(K))%P;
		N[K] = (int) r;
	}
	
	static long countSameLengthFor(int K){
		int num = Integer.parseInt((""+M).substring(0, 5)), suf = Integer.parseInt((""+M).substring(5, L));;
		long res = 0;
		for(int x1=1; x1<=9; x1++){
			for(int x2=0; x2<=9; x2++){
				for(int x3=0; x3<=9; x3++){
					for(int x4=0; x4<=9; x4++){
						for(int x5=0; x5<=9; x5++){
							int FIVE = x5+10*x4+100*x3+1000*x2+10000*x1;
							int numL = numLuckyIn(FIVE);
							if(numL>K) continue;
							if(FIVE>num) continue;
							if(FIVE==num){
								res = (res + T[suf][K-numL])%P;
							}
							else{
								res = (res + T[T.length-1][K-numL])%P;
							}
						}
					}
				}
			}
		}
		return res;
	}
	
	static int[][] T = new int[100001][10];
	
	static int L;
	
	static int numLuckyIn(int N){
		String s = ""+N;
		int t = 0;
		for(int i=0; i<s.length(); i++) if(s.charAt(i)=='4' || s.charAt(i)=='7') t++;
		return t;
	}
	
	static int[] N = new int[10]; // N[K] = number of numbers in [1,M] that contain exactly K lucky digits.
	
	static int M;
	
	static final long P = 1000000007;
	
	static StringTokenizer st;	
	static BufferedReader rd;
	static PrintWriter pw;
}