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

public class Main
	{
	static int Lucky1[];
	static int Lucky0[];
	static int NCR[][];
	static int mod=1000000007;
	static long Inverses[];
	public static void main(String args[]) throws IOException
		{
		Inverses=inverses(1000000,mod);
		Lucky0=new int[]{1,2,3,4,4,5,6,6,7,8};
		Lucky1=new int[]{0,0,0,0,1,1,1,2,2,2};
		NCR=ncr(20,20);
		BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
		int m=Integer.parseInt(c.readLine());
		int Num[]=new int[10];
		for(int i=0;i<10;i++)
			Num[i]=num(m,i);
		Num[0]--;
		int Ass[]=new int[7];
		long ans=0;
		//System.out.println(Arrays.toString(Num));
		for(int mask=0;mask<10000000;mask++)
			{
			int maskTemp=mask;
			for(int i=0;i<7;i++)
				{
				Ass[i]=maskTemp%10;
				maskTemp=maskTemp/10;
				}
			int sum=0;
			for(int i=1;i<7;i++)
				sum+=Ass[i];
			if(Ass[0]>sum)
				{
				//System.out.println("valid assignment "+Arrays.toString(Ass));
				long poss=1;
				int freq[]=new int[10];
				for(int i=0;i<7;i++)
					freq[Ass[i]]++;
				//System.out.println("freq: "+Arrays.toString(freq));
				for(int i=0;i<10;i++)
					{
					poss*=choose(Num[i],freq[i]);
					poss%=mod;
					}
				//System.out.println("poss= "+poss);
				ans+=poss;
				ans%=mod;
				}
			}
		System.out.println(ans);
		}

	private static long choose(int i,int j)
		{
		long nr=1;
		int num=j;
		for(int k=0;k<num;k++)
			{
			nr*=i;
			nr%=mod;
			i--;
			}
		return nr;
		}
	//Calculate inverses of 1-->N modulo mod
	private static long[] inverses(int N,int mod)
		{
		long inv[]=new long[N+1];
		inv[1]=1;
		for(int i=2;i<=N;i++)
			inv[i]=(mod-((mod/i)*inv[mod%i])%mod)%mod;
		return inv;
		}
	private static int[][] ncr(int N,int R)
		{
		int mod=1000000007;
		int C[][]=new int[N+1][R+1];
		for(int i=0;i<=N;i++)
			{
			C[i][0]=1;
			for(int j=1;j<=i;j++)
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		return C;
		}
	
	// numbers b/w 1 and m containing exactly k lucky digits
	public static int num(int m, int k)
		{
		//System.out.println("num ("+m+","+k+")");
		String s=Integer.toString(m);		//s.length() >=2
		if(k>s.length()||k<0)
			return 0;
		if(m<10)
			{
			if(k==0)
				return Lucky0[m];
			if(k==1)
				return Lucky1[m];
			if(k>=2)
				return 0;
			}
		//System.out.println("s is "+s);
		int first=s.charAt(0)-'0';
		//System.out.println("first is "+first);
		int ans=0;
		for(int dig=0;dig<first;dig++)		//increase the 1st digit till the first digit of s
			{
			//System.out.println("trying first digit = "+dig);
			if(dig==4||dig==7)
				{
				ans+=calc(s.length()-1,k-1);
				//System.out.println("added "+calc(s.length()-1,k-1));
				}
			else
				{
				ans+=calc(s.length()-1,k);
				//System.out.println("added "+calc(s.length()-1,k));
				}
			}
		// first digit is 'first'
		if(first==4 || first==7)
			ans+=num(Integer.parseInt(s.substring(1,s.length())),k-1);
		else
			ans+=num(Integer.parseInt(s.substring(1,s.length())),k);
		return ans;
		}
	
	// put j lucky digits in i places
	private static int calc(int i,int j)
		{
		//System.out.println("\tcalc "+i+" "+j);
		if(j<0 || j>i)
			return 0;
		return NCR[i][j]*pow(2,j)*pow(8,i-j);
		}

	private static int pow(int a,int b)
		{
		int ans=1;
		while (b>0)
			{
			ans=ans*a;
			b--;
			}
		return ans;
		}
	
	public static int numLucky(int n)
		{
		int ans=0;
		while(n>0)
			{
			if(n%10==4||n%10==7)
				ans++;
			n=n/10;
			}
		return ans;
		}
	}