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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ProblemB {
	
	static final long MOD = 1000000007;
	
	
	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		long m = Long.valueOf(s.readLine());
		char[] mstr = String.valueOf(m).toCharArray();
		int keta = mstr.length;
		
		long[][][][] dp = new long[keta+1][11][3][2];
		dp[0][0][0][1] = 1;
		for (int i = 0 ; i < keta ; i++) {
			for (int j = 0 ; j < 10 ; j++) {
				for (int flg = 0 ; flg <= 2; flg++) {
					for (int zero = 0 ; zero <= 1; zero++) {
						if (dp[i][j][flg][zero] == 0) {
							continue;
						}
						long base = dp[i][j][flg][zero];
						for (int d = 0 ; d <= 9 ; d++) {
							int ti = i+1;
							int tj = (d == 4 || d == 7) ? j+1 : j;
							int tz = (d == 0) ? 1 : 0;
							int digit = mstr[keta-i-1] - '0';
							int tflg = 0;
							if (d > digit) {
								tflg = 1;
							} else if (d == digit) {
								tflg = flg;
							} else {
								tflg = 2;
							}
							dp[ti][tj][tflg][tz] += base;
						}
					}
				}
			}
		}
		
		long[] cnt = new long[10];
		for (int k = 1 ; k <= keta ; k++) {
			for (int j = 0 ; j <= 9 ; j++) {
				for (int f = 0 ; f <= 2 ; f++) {
					if (k == keta && f == 1) {
						continue;
					}
					cnt[j] += dp[k][j][f][0];
				}
			}
		}
//		debug(cnt);
//		debug(countTill(m));
		
		long ans = 0;
		for (int my = 1 ; my <= 9 ; my++) {
			long ct = cnt[my];
			if (ct == 0) {
				continue;
			}
			cnt[my]--;
			long op = 0;
			for (int other = 0 ; other <= 999999 ; other++) {
				int oc = other;
				int ocnt = 0;
				while (oc >= 1) {
					ocnt += oc % 10;
					oc /= 10;
				}
				if (my <= ocnt) {
					continue;
				}
				
				long add = 1;
				{
					int oct = other;
					for (int c = 0 ; c < 6 ; c++) {
						int od = oct % 10;
						add *= cnt[od];
						add %= MOD;
						cnt[od]--;
						oct /= 10;
					}
				}
				{
					int oct = other;
					for (int c = 0 ; c < 6 ; c++) {
						int od = oct % 10;
						cnt[od]++;
						oct /= 10;
					}
				}
				op += add;
				op %= MOD;
			}
			ans += (ct * op) % MOD;
			ans %= MOD;
			cnt[my]++;
		}
		out.println(ans);
		out.flush();
	}
	
	static long[] countTill(long a) {
		long[] cnt = new long[10];
		for (long i = 1 ; i <= a ; i++) {
			cnt[count(i)]++;
		}
		return cnt;
	}
	
	static int count(long a) {
		int cnt = 0;
		while (a >= 1) {
			long d = a % 10;
			if (d == 4 || d == 7) {
				cnt++;
			}
			a /= 10;
		}
		return cnt;
	}
	


	public static void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}