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.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	static int[] numDigits;

	static final int MOD = 1000000007;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		numDigits = new int[12];
		numDigits[0] = -1;
		int max = readInt();
		dfs(Integer.toString(max), 0, true, 1);
		long ret = 0;
		for(int i = 1; i < numDigits.length; i++)	{
			if(numDigits[i] == 0)
				continue;
			for(int a = 0; a < i; a++)	{
				for(int b = 0; a+b<i; b++)	{
					for(int c = 0; a +b+c < i; c++)	{
						for(int d = 0; a+b+c+d < i; d++)	{
							for(int e = 0; a+b+c+d+e < i; e++)	{
								for(int f = 0; a+b+c+d+e+f < i; f++)	{
									int[] numCount = new int[12];
									numCount[a]++;
									numCount[b]++;
									numCount[c]++;
									numCount[d]++;
									numCount[e]++;
									numCount[f]++;
									long curr = numDigits[i];
									for(int k = 0; k < numCount.length; k++)	{
										for(int x = 0; x < numCount[k]; x++)	{
											curr *= numDigits[k] - x;
											curr %= MOD;
										}
									}
									ret += curr;
									ret %= MOD;
								}
							}
						}
					}
				}
			}
		}
		pw.println(ret);
		pw.close(); 
	}

	public static void dfs(String max, int numLucky, boolean match, int scale)	{
		if(max.length() == 0)	{
			numDigits[numLucky] += scale;
		}
		else	{
			if(match)	{
				int notLucky = 0;
				int lucky = 0;
				for(int i = 0; i < max.charAt(0) - '0'; i++)	{
					if(i == 4 || i == 7)
						lucky++;
					else
						notLucky++;
				}
				if(notLucky != 0)
					dfs(max.substring(1), numLucky, false, scale * notLucky);
				if(lucky != 0)
					dfs(max.substring(1), numLucky+1, false, scale * lucky);
				dfs(max.substring(1), numLucky + (max.charAt(0) == '4' || max.charAt(0) == '7' ? 1 : 0), true, scale);
			}
			else	{
				dfs(max.substring(1), numLucky, false, 8*scale);
				dfs(max.substring(1), numLucky+1, false, 2*scale);
			}
		}
	}

	/* NOTEBOOK CODE */

	public static void loadArray(int[][] grid) throws IOException {
		for(int[] a: grid)
			loadArray(a);
	}

	public static void loadArray(int[] in) throws IOException {
		for(int i = 0; i < in.length; i++)
			in[i] = readInt();
	}

	public static void loadArray(long[] in) throws IOException {
		for(int i = 0; i < in.length; i++)
			in[i] = readLong();
	}


	private static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				pw.close();
				System.exit(0);
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}