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

public class test2
{
	 static long mod = 1000000007;
	static int dp[][][];
	static long dp2[][][];
	static long pow(long a , long b , long c)
	   {
		   
		   if(b==0)
			   return 1;
		   
		   long ans = pow(a,b/2,c);
		   if(b%2 == 0)
			   return ans*ans%c;
		   
		   return ans*ans%c*a%c;
	   }
	   
	   static long modInverse(long a , long b)
	   {
		   return pow(a,b-2,mod);
	   }
	
	static int ways(int pos , int good , int bin , String s)
	{
		if(good < 0)
			return 0;
		
		if(pos == s.length())
		{
			if(good == 0)
				return 1;
			
			return 0;
		}
		
		if(dp[pos][good][bin] != -1)
			return dp[pos][good][bin];
		
		dp[pos][good][bin] = 0;
		int ch = s.charAt(pos)-'0';
		for(int i = 0 ; i <= 9 ; i++)
		{
			if(bin == 1 && i > s.charAt(pos)-'0')
				break;
			
			
			if(ch != i)
			{
				if(i == 4 || i == 7)
					dp[pos][good][bin] += ways(pos+1,good-1,0,s);
				
				else
					dp[pos][good][bin] += ways(pos+1,good,0,s);
			}
			
			else
			{
				if(i == 4 || i == 7)
				{
					if(bin == 1)
						dp[pos][good][bin] += ways(pos+1,good-1,1,s);
					
					else
						dp[pos][good][bin] += ways(pos+1,good -1, 0 , s);
				}
				
				else
				{
					if(bin == 1)
						dp[pos][good][bin] += ways(pos+1,good,1,s);
					
					else
						dp[pos][good][bin] += ways(pos+1,good , 0 , s);
				}
			}
		}
		
		return dp[pos][good][bin];
	}
	
	static long ways2(int pos , int sum , int left ,  int arr[])
	{
		if(sum < 0 || left < 0)
			return 0;
		
		if(pos == arr.length)
		{
			if(sum >= 0 && left == 0)
				return 1;
			
			return 0;
		}
		
		if(dp2[pos][sum][left] != -1)
			return dp2[pos][sum][left];
		
		dp2[pos][sum][left] = 0;
		for(int k = 0 ; k <= Math.min(left,arr[pos]) ; k++)
		{
			long fact = 1;
			for(long z = arr[pos]; z > arr[pos]-k ; z--)
			{
				fact = fact*z%mod;
			}
			long fact2 = 1;
			for(long z = 1 ; z <= k ; z++)
			{
				fact2 = fact2*z%mod;
			}
			
			dp2[pos][sum][left] += fact*modInverse(fact2,mod)%mod*ways2(pos+1,sum-k*pos, left-k,arr)%mod;
			dp2[pos][sum][left] %= mod;
		}
		return dp2[pos][sum][left];
	}
       public static void main(String []args) throws IOException
       {
             Scanner sc = new Scanner(System.in);
            int m = sc.nextInt();
            int dig = 0;
            for(int i = m ; i >  0 ; i = i/10)
            {
            	dig++;
            }
            //System.out.println("break");
            String s = m+"";
            dp = new int[dig][dig+1][2];
            for(int i = 0 ; i < dig ; i++)
            {
            	for(int j = 0 ; j <= dig ; j++)
            	{
            		dp[i][j][0] = -1;
            		dp[i][j][1] = -1;
            	}
            }
            
            dp2 = new long[dig+1][dig+1][7];
            for(int i = 0 ; i <= dig ; i++)
            {
            	for(int j = 0 ; j <= dig ; j++)
            	{
            		for(int k = 0 ; k <= 6 ; k++)
            		{
            		dp2[i][j][k] = -1;
            		}
            	}
            }
            
            long ans = 0;
           
            int arr[] = new int[dig+1];
            arr[0] = ways(0,0,1,s)-1;
            
            for(int i = 1 ; i <= dig ; i++)
            {
            	arr[i] = ways(0,i,1,s);
            }
            
           
          
            for(int i = 1 ; i <= dig ; i++)
            {
            	long x = ways2(0,i-1,6,arr);
            	//System.out.println(x);
            	x = x*720%mod;
            	ans += x*arr[i]%mod;
            	ans %= mod;
            }
            
           
            System.out.println(ans);
          
         
       }
}