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.*;
import java.math.BigInteger;
public class LittleElephantAndElections 
{
	public static final int MOD = 1000000007;
	
	public static boolean[] used;
	public static long result;
	public static long[][][] dp;
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		
		int m = in.nextInt();
		
		int[] number = new int[11];
		for(int x = 0; x < 11; x++)
		{
			number[10 - x] = (m / (int)(Math.pow(10, x))) % 10;
		}
		
		dp = new long[2][11][11];
		
		if(number[0] == 4 || number[0] == 7)
		{
			dp[0][0][1] = 1;
		}
		else
		{
			dp[0][0][0] = 1;
		}
		
		for(int y = 0; y < number[0]; y++)
		{
			if(y == 4 || y == 7)
			{
				dp[1][0][1]++;
			}
			else
			{
				dp[1][0][0]++;
			}
		}
		
		for(int i = 1; i < dp[0].length; i++)
		{
			for(int j = 0; j < dp[0][0].length; j++)
			{
				if((number[i] == 4 || number[i] == 7) && j > 0)
				{
					dp[0][i][j] = dp[0][i - 1][j - 1];
				}
				else if(!(number[i] == 4 || number[i] == 7))
				{
					dp[0][i][j] = dp[0][i - 1][j];
				}
				
				for(int k = 0; k < number[i]; k++)
				{
					if((k == 4 || k == 7) && j > 0)
					{
						dp[1][i][j] += dp[0][i - 1][j - 1];
					}
					else if(!(k == 4 || k == 7))
					{
						dp[1][i][j] += dp[0][i - 1][j];
					}
					
					dp[1][i][j] %= MOD;
				}
				
				if(j > 0)
				{
					dp[1][i][j] += dp[1][i - 1][j - 1] * 2;
					dp[1][i][j] %= MOD;
				}
				
				dp[1][i][j] += dp[1][i - 1][j] * 8;
				dp[1][i][j] %= MOD;
			}
		}
		
		dp[1][10][0]--;
		
		result = 0;
		long sum = dp[0][10][0] + dp[1][10][0];
		for(int z = 1; z < dp[0][0].length; z++)
		{
			used = new boolean[16];
			combinations(0, 10, z);
		}
		
		System.out.println(result);
	}
	
	public static long choose(long n, long r)
	{
		if(n < r)
		{
			return 0;
		}
		
		BigInteger ret = BigInteger.ONE;
		
		for(long i = n; i > n - r; i--)
		{
			ret = ret.multiply(new BigInteger("" + i));
		}
		
		for(int j = 2; j <= r; j++)
		{
			ret = ret.divide(new BigInteger("" + j));
		}
		
		return ret.mod(new BigInteger("" + MOD)).longValue();
	}
	
	public static void combinations(int n, int r, int z)
	{
		if(r == 0)
		{
			int[] parties = new int[11];
			int index = 0;
			int total = 0;
			for(int i = 0; i < used.length; i++)
			{
				if(!used[i])
				{
					parties[index]++;
					total += index;
				}
				else
				{
					index++;
				}
			}
			
			if(total < z)
			{
				long others = 1;
				for(int j = 0; j < parties.length; j++)
				{
					others *= choose(dp[0][10][j] + dp[1][10][j], parties[j]);
					others %= MOD;
				}
				
				others *= 720;
				others %= MOD;
				
				result += (dp[0][10][z] + dp[1][10][z]) * others;
				result %= MOD;
			}
		}
		else if(n < used.length)
		{
			used[n] = true;
			combinations(n + 1, r - 1, z);
			used[n] = false;
			combinations(n + 1, r, z);
		}
	}
}