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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// int a,b,c;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
	//static int mod = 1000000009,r=0;
   // static int dx[]={1,-1,0,0};
//	static int dy[]={0,0,1,-1};
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
//  static int dy[]={0,0,1,-1,1,-1,1,-1};
	//static long H,L;
	//static Set<Integer> set = new HashSet<Integer>();
	static long d[],f[];
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //  
	Reader sc = new Reader(System.in);
  // while( ){
	  // int  n=sc.nextInt(),m=sc.nextInt();//a[]=new int[n],b[]=new int[n];
	
int	n=sc.nextInt(), l=(""+n).length();
long as=0;
d=new long[10];
f=new long[11];
   if(n<10){
	   if( n<8 ) System.out.println(0);
	   else if( n==8 )System.out.println(1440);
	   else System.out.println(1440*7);
	   return;}
   
   else{
     int dp[][][]=new int[l+1][11][2];
	 int w[]={ 0,0,0,0,0,1,1,1,2,2},
		ww[]={ 0,1,2,3,4,4,5,6,6,7},h=0;
	 int te=(n+"").charAt(0)-'0';
	 dp[1][0][0]=ww[te];
	 dp[1][1][0]=w[te];
	 if( 4==te  || 7==te){dp[1][1][1]++;h++;} else dp[1][0][1]++;		 
	 for(int j=2; j<=l ;j++){
		 te=(n+"").charAt(j-1)-'0';
		 if( te==4 || te==7)h++;
		 for(int t=0; t<=j; t++){
         dp[j][t][1]=t==h? 1:0;
		 dp[j][t][0]=8*dp[j-1][t][0]+ww[te]*dp[j-1][t][1];
		if(t!=0)dp[j][t][0]+=2*dp[j-1][t-1][0]+w[te]*dp[j-1][t-1][1];		
		 }
	 }
	 long e=0;
	 for(int t=1; t<10 ;t++){  e+=dp[l][t][0]+dp[l][t][1]; f[t] = dp[l][t][0]+dp[l][t][1] ;}
	 f[0]+=n-e;
	 for(int t=0; t<9 ;t++)rep(1,t,f[t],t,1,6);
	 for(int t=1; t<=l ;t++){
		 e=0;
		 for(int j=0; j<t ;j++){
			 e+=d[j];
			 e%=mod;
		 }
		as+=e*f[t];
		as%=mod;
	 }
//  720997200 463359988
	                  
   }
  
	System.out.println(as);

	
}

 static void rep(int a,int b,long c,int pr,int su,int ex){
	 if(a==6){ d[b]+=(c*com(ex,su))%mod ; d[b]%=mod; return;}
	 
	 if( pr==0 )rep(++a,b,c*(f[0]-su)%mod,0,++su,ex);
	 else {
		 rep(a+1,b,c*f[0]%mod,0,1,ex);
		 for(int i=pr; i+b<=8 && 1<=f[i]-su; i++){
			 rep(a+1,b+i,c*( i==pr? (f[i]-su):(f[i]*com(ex,su)) )%mod, i , i==pr? su+1:1,i==pr? ex:ex-su);
		 }
	 }
	 
 }

static long com( int n, int m ) {
    if( n < m || m < 0 ) {
        throw new IllegalArgumentException( "invalid( n : " + n + ", m : " + m + ")" );
    }
    long c = 1;
    m = ( n - m < m ? n - m : m );
    for( int ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++ ) {
        c *= ns;
        c /= ms;
    }
    return c;
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}
}



class Reader
{
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}




/*class P implements Comparable<P>{
//	implements Comparable<P>
	int a,b,c;
	P(int a,int b,int c){
		this.a=a;
		this.b=b;
		this.c=c;
	} 
	public int compareTo(P x){
	   	 return b-x.b; 
	   }
}
*/