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 Main {
//	static Scanner in; static int next() throws Exception {return in.nextInt();};
	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;
	static PrintWriter out;
	static int mod = 1000000007;

	static int mult(int x, int y) {
		return (int)(((long) x * y) % mod);
	}

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int m = next();

		int[] ten= new int[10];
		ten[0] = 1;
		for (int i = 1; i < 10; i++) ten[i] = 10 * ten[i - 1];

		int[] d = new int[10];
		int mm = m;
		for (int i = 0; i < 10; i++) {
			d[i] = mm % 10;
			mm /= 10;
		}
		
		int[][] kol = new int[10][10];
		kol[0][0] = 1;
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j <= i; j++) {
				kol[i + 1][j] += kol[i][j] * 8;
				kol[i + 1][j + 1] += kol[i][j] * 2;
			}
		}
		
		int[] count = new int[11];

		int sum = 0;
		for (int i = 9; i >= 0; i--) {
			int without = d[i];
			int with = 0;
			if (d[i] > 4) {
				without--;
				with++;
			}
			if (d[i] > 7) {
				without--;
				with++;
			}

			for (int j = 0; j <= i; j++) {
				count[j + sum] += kol[i][j] * without;
				count[j + sum + 1] += kol[i][j] * with;
			}

			if (d[i] == 4 || d[i] == 7) sum++;
		}

		count[sum] ++;
		count[0] --;
		
/*		for (int i = 0; i < 10; i++) {
			for (int j = 0; j <= i; j++) out.print(kol[i][j] + " ");
			out.println();
		}
		out.println();
		for (int i = 0; i < 10; i++) out.print(count[i] + " ");
		out.println();*/

		int answ = 0;
		
		int[][][] sum6 = new int[10][7][60];

		int[][] c = new int[9][9];
		for (int i = 0; i < 9; i++) {
			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];
		}

		sum6[0][0][0] = 1;
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j <= 6; j++) {
				int mul = 1;
				for (int t = 0; j + t <= 6; t++) {
					for (int s = 0; s <= j*9; s++) 
						sum6[i + 1][j + t][s + i*t] = (sum6[i + 1][j + t][s + i*t] + mult(mult(sum6[i][j][s], mul), c[6 - j][t])) % mod;
					mul = mult(mul, count[i] - t);
				}
			}
		}

//		for (int i = 0; i < 10; i++) out.print(sum6[9][6][i] + " ");
//		out.println();

		for (int i = 1; i < 10; i++)
			for (int j = 0; j < i; j++) answ = (answ + mult(sum6[9][6][j], count[i])) % mod;

		out.println(answ);

		out.close();
	}
}