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.Scanner;


public class B {
	public static final boolean DEBUG = true;
	Scanner sc;
	
	public void debug(Object o) {
		if (DEBUG) {
			int ln = Thread.currentThread().getStackTrace()[2].getLineNumber();
			String fn = Thread.currentThread().getStackTrace()[2].getFileName();
			System.out.println("(" + fn + ":" + ln+ "): " + o);
		}
	}
	
	public void pln(Object o) {
		System.out.println(o);
	}
	
	
	int[] num = new int[20];
	void computeN(int m) {
		int[][][] nr = new int[20][2][100];	// pos, lt, num47
		
		String sm = "" + m;
		int lg = sm.length();
		
		int a = sm.charAt(0) - '0';
		for (int i=0; i<a; i++) {
			if (i!=4 && i!=7) {
				nr[0][1][0]++;
			}
			else {
				nr[0][1][1]++;
			}
		}
		if (a==4 || a==7) {
			nr[0][0][1]++;
		}
		else {
			nr[0][0][0]++;
		}
		for (int i=1; i<lg; i++) {
			for (int dig=0; dig<10; dig++) {
				int x = 0;
				if (dig==4 || dig==7) x=1;
				
				for (int num=0; num<20; num++) {
					if (dig + '0' < sm.charAt(i)) {
						nr[i][1][num+x] += nr[i-1][0][num] + nr[i-1][1][num];
					}
					else if (dig + '0' == sm.charAt(i)) {
						nr[i][1][num+x] += nr[i-1][1][num];
						nr[i][0][num+x] += nr[i-1][0][num];
					}
					else if (dig + '0' > sm.charAt(i)) {
						nr[i][1][num+x] += nr[i-1][1][num];
					}
				}
			}
		}
		
		for (int k=0; k<20; k++) {
			num[k] = nr[lg-1][1][k] + nr[lg-1][0][k];
		}
	}
	
	long result = 0;
	long mod = 1000000007;
	public void addCount(int max, int pos, long mul) {
		if (pos == 6) {
			result = (result + mul) % mod;
		}
		else {
			for (int i=0; i<max; i++) {
				if (num[i] > 0) {
					num[i]--;
					addCount(max-i, pos+1, (mul * (1+num[i])) % mod);
					num[i]++;
				}
			}
		}
	}
	public void run() {
		sc = new Scanner(System.in);		
		int m = sc.nextInt();
		
		computeN(m);
		num[0]--;
		
//		for (int i=0; i<10; i++) pln(i + " " + num[i]);
		
		for (int i=0; i<10; i++) {
			if (num[i] > 0) {
				addCount(i, 0, num[i]);
			}
		}
		pln(result);
	}
	public static void main(String[] args) {
		B t = new B();
		t.run();
	}
}