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

public class B {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	static final int MOD = 1_000_000_007;
	
	static final int[] POW2 = new int[10];
	static final int[] POW8 = new int[10];
	{
		POW2[0] = POW8[0] = 1;
		for (int i = 1; i < 10; i++) {
			POW2[i] = POW2[i - 1] * 2;
			POW8[i] = POW8[i - 1] * 8;
		}
	}
	
	static final int[][] c = new int[10][];
	{
		for (int i = 0; i < c.length; i++) {
			c[i] = new int[i + 1];
			c[i][0] = c[i][i] = 1;
			for (int j = 1; j < i; j++)
				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
	
	int[] getCnt(int m) {
		m++;
		int[] res = new int[10];
		char[] x = Integer.toString(m).toCharArray();
		int prefLucky = 0;
		for (int i = 0; i < x.length; i++) {
			int dig = x[i] - '0';
			for (int j = 0; j < dig; j++) {
				int curLucky = prefLucky + (isLucky(j) ? 1 : 0);
				int sufLen = x.length - 1 - i;
				
				for (int k = 0; k <= sufLen; k++) {
					res[curLucky + k] += c[sufLen][k] * POW2[k] * POW8[sufLen - k];
				}
				
			}
			prefLucky += (isLucky(dig) ? 1 : 0);
		}
		res[0]--; // no zero
		return res;
	}

	boolean isLucky(int j) {
		return j == 4 || j == 7;
	}
	
	int[] cnt;

	void solve() throws IOException {
		int m = nextInt();
		cnt = getCnt(m);
		
		System.err.println(Arrays.toString(cnt));
		
		int[][] dp = new int[7][10];
		dp[0][0] = 1;
		for (int i = 0; i < 10; i++) {
			for (int j = 6; j >= 0; j--)
				for (int k = 9; k >= 0; k--) {
					int ways = 1;
					for (int pick = 1; j + pick <= 6 && k + pick * i <= 9 && pick <= cnt[i]; pick++) {
						ways = (int)((long)ways * (cnt[i] - pick + 1) % MOD);
						dp[j + pick][k + pick * i] += (int)((long)dp[j][k] * ways % MOD * c[6 - j][pick] % MOD);
						if (dp[j + pick][k + pick * i] >= MOD)
							dp[j + pick][k + pick * i] -= MOD;
					}
				}
		}		
		
		int[] res = dp[6];
		
		int sum = 0;
		
		int ans = 0;
		
		for (int i = 1; i < cnt.length; i++) {
			sum += res[i - 1];
			if (sum >= MOD)
				sum -= MOD;
			ans += (int)((long)sum * cnt[i] % MOD);
			if (ans >= MOD)
				ans -= MOD;
		}
		
		out.println(ans);
	}

	B() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}