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.*;
public class D{
	static final int MOD = 1000000007;
	static final int MAX1 = 11;
	static final int MAX2 = 11;
	static final int MAX3 = 2;
	static final int MAX4 = 11;
	static int [] m;
	static int [][][][] memo = new int[MAX1][MAX2][MAX3][MAX4];
	static int [] digits(String m){
		final int n = m.length();
		final int [] res = new int[n];
		for (int i = 0; i < n; ++i){
			res[i] = m.charAt(i) - '0';
		}
		return res;
	}
	static int score(int d){
		return d == 4 || d == 7 ? 1 : 0;
	}
	static int rec(int i, int j, int eq, int count){
		if (i == m.length){
			return j == count ? 1 : 0;
		}
		if (memo[i][j][eq][count] != -1){
			return memo[i][j][eq][count];
		}
		int res = 0;
		if (eq == 1){
			for (int d = 0; d <= 9; ++d){
				if (d > m[i]){
					break;
				}
				if (d == m[i]){
					res += rec(i + 1, j + score(d), eq, count);
				}else{
					res += rec(i + 1, j + score(d), 0, count);
				}
			}
		}else{
			res += 8*rec(i + 1, j, 0, count) + 2*rec(i + 1, j + 1, 0, count);
		}
		return memo[i][j][eq][count] = res;
	}
	public static void main(String [] args){
		Scanner s = new Scanner(System.in);
		m = digits(s.nextLine());
		for (int [][][] m1 : memo){
			for (int [][] m2 : m1){
				for (int [] m3 : m2){
					Arrays.fill(m3, -1);
				}
			}
		}
		int [] cnt = new int[11];
		for (int i = 0; i <= 10; ++i){
			cnt[i] = rec(0, 0, 1, i);
		}
		cnt[0]--;
		long res = 0;
		for (int a = 0; a <= 9; ++a){
			for (int b = 0; b <= 9; ++b){
				for (int c = 0; c <= 9; ++c){
					for (int d = 0; d <= 9; ++d){
						for (int e = 0; e <= 9; ++e){
							for (int f = 0; f <= 9; ++f){
								long p = cnt[a]--;
								p *= cnt[b]--;
								p %= MOD;
								p *= cnt[c]--;
								p %= MOD;
								p *= cnt[d]--;
								p %= MOD;
								p *= cnt[e]--;
								p %= MOD;
								p *= cnt[f]--;
								p %= MOD;
								if (cnt[a] >= 0
									 && cnt[b] >= 0
									 && cnt[c] >= 0
									 && cnt[d] >= 0
									 && cnt[e] >= 0
									 && cnt[f] >= 0){
									for (int i = a + b + c + d + e + f + 1; i <= 9; ++i){
										res += p*cnt[i];
										res %= MOD;
									}
								}
								cnt[a]++;
								cnt[b]++;
								cnt[c]++;
								cnt[d]++;
								cnt[e]++;
								cnt[f]++;
							}
						}						
					}				
				}
			}
		}
		System.out.println(res);
	}
}