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.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Main implements Runnable {
	
	static final long MOD = 1000000007;
	
	int m;
	long count [];
	long d[][][];
	
	int getLength (int num) {
		int ret = 0;
		while (num > 0) {
			num /= 10;
			ret++;
		}
		return ret;
	}
	
	int[] getArray (int num) {
		String str = Integer.toString(num);
		int arr [] = new int [str.length()];
		for (int i = 0; i < str.length(); i++) {
			arr [i] = str.charAt(i) - '0';
		}
		return arr;
	}
	
	void solve() throws Exception {
		
		long C [][] = new long [10][10];
		for (int i = 0; i < 10; 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]) % MOD;
			}
		}
		
		m = sc.nextInt();
		count = new long [10];
		int n = getLength(m);
		
		d = new long [n + 1][10][2];
		int arr [] = getArray(m);
		
		d[0][0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int cnt = 0; cnt <= 9; cnt++) {
				for (int flag = 0; flag < 2; flag++) {
					if (d[i][cnt][flag] > 0) {
						int l = 0;
						int r = 9;
						if (flag == 0) {
							r = arr[i];
						}
						for (int dig = l; dig <= r; dig++) {
							int toflag = 1;
							if (flag == 0 && dig == r) toflag = 0;
							int tocnt = cnt;
							if (dig == 4 || dig == 7) tocnt = cnt + 1;
							d[i + 1][tocnt][toflag] += d[i][cnt][flag];
						}
						
					}
				}
			}
		}
		
		for (int i = 0; i <= 9; i++) {
			count[i] = d[n][i][0] + d[n][i][1];
		}
		count[0]--;
		
		long c[][][] = new long [10][10][7];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j][0] = 1;
				if (count[j] > 0) {
					long all = 1;
					long current = count[j];
					if (i == j) current--;
					for (int k = 1; k <= 6; k++) {
						all = (all * current) % MOD;
						c[i][j][k] = all;
						current--;
					}
				}
				
			}
		}
		
		long ans = 0;
		
		for (int select = 1; select < 10; select++) {
			if (count[select] > 0) {
				long d[][][] = new long [11][7][select];
				d[0][0][0] = 1;
				for (int i = 0; i < 10; i++) {
					for (int j = 0; j <= 6; j++) {
						for (int sum = 0; sum < select; sum++) {
							if (d[i][j][sum] > 0) {
								for (int k = 0; k + j <= 6; k++) {
									if (k * i + sum < select && c[select][i][k] > 0) {
										long mult = (d[i][j][sum] * c[select][i][k]) % MOD;
										mult = (mult * C[6 - j][k]) % MOD;
										d[i + 1][j + k][sum + k * i] += mult;
										d[i + 1][j + k][sum + k * i] %= MOD;
									}
								}
							}
						}
					}
				}
				
				long cur = 0;
				for (int sum = 0; sum < select; sum++) {
					cur += d[10][6][sum];
					cur %= MOD;
				}
				
				cur = (cur * count[select]) % MOD;
				ans = (ans + cur) % MOD;
			}
		}
		
		out.println(ans);
		
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Main.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Main(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}

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

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

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

}