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
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class magic2 {
	static final long mod =1000000007;
	static int[] array;
	static int N;
	static long[][][] memo;
	static long good[];
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String temp = sc.next();
		array = new int[temp.length()];
		N = array.length;
		memo = new long[11][11][11];
		for(long[][] x : memo)
			for(long[] y : x)
				Arrays.fill(y,-1);
		for(int a=0;a<temp.length();a++)
			array[a]=temp.charAt(a)-'0';
		
		good = new long[10];
		for(int a=0;a<10;a++)
			good[a]=DP(0,array[0],a);
		
		good[0]--;
		long ans = 0;
		for(int a0=0;a0<=6;a0++){
			for(int a1=0;a1+a0<=6;a1++){
				for(int a2=0;a2+a1+a0<=6;a2++){
					for(int a3=0;a3+a2+a1+a0<=6;a3++){
						for(int a4=0;a4+a3+a2+a1+a0<=6;a4++){
							for(int a5=0;a5+a4+a3+a2+a1+a0<=6;a5++){
								for(int a6=0;a6+a5+a4+a3+a2+a1+a0<=6;a6++){
									for(int a7=0;a7+a6+a5+a4+a3+a2+a1+a0<=6;a7++){
										for(int a8=0;a8+a7+a6+a5+a4+a3+a2+a1+a0<=6;a8++){
											int dig = (a1*1)+(a2*2)+(a3*3)+(a4*4)+(a5*5)+(a6*6)+(a7*7)+(a8*8);
											if(a0+a1+a2+a3+a4+a5+a6+a7+a8!=6)continue;
											if(dig>=9)continue;
											long cur = 0;
											for(int a=dig+1;a<=9;a++){
												cur+=good[a];
												cur%=mod;
											}

											long thing = good[0];
											for(int b=0;b<a0;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[1];
											for(int b=0;b<a1;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[2];
											for(int b=0;b<a2;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[3];
											for(int b=0;b<a3;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[4];
											for(int b=0;b<a4;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[5];
											for(int b=0;b<a5;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[6];
											for(int b=0;b<a6;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[7];
											for(int b=0;b<a7;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
											
											thing = good[8];
											for(int b=0;b<a8;b++){
												cur*=thing;
												cur%=mod;
												thing--;
											}
										//	cur%=mod;
											long other = fac(6);
											other/=fac(a0);
											other/=fac(a1);
											other/=fac(a2);
											other/=fac(a3);
											other/=fac(a4);
											other/=fac(a5);
											other/=fac(a6);
											other/=fac(a7);
											other/=fac(a8);
											cur*=other;
											cur%=mod;
											ans+=cur;
											ans%=mod;
									/*		if(cur!=0){
												System.out.println(cur);
												System.out.println(haha+" - "+a0+" "+a1+" "+a2+" "+a3+" "+a4+" "+a5+" "+a6+" "+a7+" "+a8);
											}*/
										}
									}
								}
							}
						}
					}
				}
			}
			
		}
//		for(int a=9;a>=1;a--){
//			long me = good[a];
//			long lower = DP2(a,0,a-1,0);
//			System.out.println(a+" "+me+" "+lower);
//			//for(int b=1;b<=6;b++){
//				me*=lower;
//			//	me%=mod;
//		//		lower--;
//			//}
//			ans+=me;
//	//		ans%=mod;
//		}
		//System.out.println(Arrays.toString(good));
		out.println(ans%mod);
		//out.println(ans);
		out.close();
		
	}
	private static long fac(int groups) {
		long ans = 1;
		while(groups>1){
			ans*=groups;
			groups--;
		}
		return ans;
	}
	private static long DP2(int limit, int person, int pos, int used) {
		if(limit<=0)return 0;
		if(person==6){
			return 1;
		}
		long ans = 0;
		for(int a=pos;a>=0;a--){
			if(used>good[a])continue;
			ans+=DP2(limit-a,person+1,a,pos==a?used+1:0)*Math.max((good[a]-used),0);
		//	ans%=mod;
		}
		return ans;
	
	}

	private static long DP(int pos, int cap, int many) {
		if(many<0)return 0;
		if(memo[pos][cap][many]!=-1)return memo[pos][cap][many];
		if(pos==N){
			if(many==0)return memo[pos][cap][many]=1;
			else return memo[pos][cap][many]=0;
		}
		long ans = 0;
		for(int a=0;a<=cap;a++){
			if(a==10)continue;
			if(a==cap&&pos<N-1)ans+=DP(pos+1,array[pos+1],(a==4||a==7)?many-1:many);
			else ans+=DP(pos+1,10,(a==4||a==7)?many-1:many);
		}
		return memo[pos][cap][many]=ans;
		
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) throws Exception {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer(br.readLine().trim());
		}

		public int numTokens() throws Exception {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine().trim());
				return numTokens();
			}
			return st.countTokens();
		}

		public boolean hasNext() throws Exception {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine().trim());
				return hasNext();
			}
			return true;
		}

		public String next() throws Exception {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine().trim());
				return next();
			}
			return st.nextToken();
		}

		public double nextDouble() throws Exception {
			return Double.parseDouble(next());
		}

		public float nextFloat() throws Exception {
			return Float.parseFloat(next());
		}

		public long nextLong() throws Exception {
			return Long.parseLong(next());
		}

		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}

		public String nextLine() throws Exception {
			return br.readLine();
		}
	}

}
