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
import java.util.*;
import java.io.*;
public class D {
	public static int[] nextCombination(int[] x ,int m){
		if( x[x.length-1] < m-1 ){
			x[x.length-1]++;
			return x;
		} else {
			for(int i = x.length-2; i >= 0; i--){
				if( x[i+1] - x[i] > 1 ){
					x[i]++;
					for(int j = i+1; j < x.length; j++){
						x[j] = x[j-1]+1;
					}
					return x;
				}
			}
		}
		return x;
	}
	public int combination(int n, int m){
		int ret = 1;
		int temp = 1;
		while( temp <= m ){
			ret *= n;
			ret /= temp;
			temp++;
			n--;
		}
		return ret;
	}
	public int combination(int[] x){
		int ret = 720;
		for(int i = 0; i < x.length; i++){
			ret /= permutation(x[i], x[i], 1000000);
		}
		return ret;
	}
	public long permutation(int n, int m, int mod){
		long ret = 1;
		while( m-- > 0 ){
			ret *= n;
			n--;
			ret %= mod;
		}
		return ret;
	}
	public void solve() throws IOException {
		int mod = 1000000007;
		int m = nextInt();
		if( m <= 7 ){
			writer.println(0);
			return;
		}
		int[] num = new int[10];
		int temp = m;
		for(int i = 9; i >= 0; i--){
			num[i] = temp%10;
			temp /= 10;
		}
		int[] dp = new int[10];
		int count = 0; // the number of 4, 7 in m.
		for(int i = 0; i < 10; i++){			
			int[] next = new int[10];
			for(int j = 0; j < 10; j++){
				if( j >= 1 ){
					next[j] = dp[j-1]*2;
				}
				next[j] += dp[j]*8;
			}
			if( num[i] <= 4 ){
				next[count] += num[i];
			} else if( num[i] <= 7 ){
				next[count] += num[i]-1;
				next[count+1] += 1;
			} else {
				next[count] += num[i]-2;
				next[count+1] += 2;
			}
			if( num[i] == 4 || num[i] == 7 ){
				count++;
			}
			dp = next;
		}
		dp[count]++; // include m
		dp[0]--; // exclude 000000000
		long ans = 0;
		int rep = combination(16, 7);
		int[] p = new int[7];
		for(int i = 0; i < 7; i++){
			p[i] = i;
		}
		while( rep-- > 0 ){
			int[] c = new int[7];
			c[0] = p[0];
			for(int i = 1; i < 7; i++){
				c[i] = p[i]-i;
			}
			int sum = 0;
			for(int i = 0; i < 6; i++){
				sum += c[i];
			}
			if( sum >= c[6] ){
				p = nextCombination(p, 16);
				continue;
			}
			int[] x = new int[10];
			for(int i = 0; i < 7; i++){
				x[c[i]]++;
			}
			long perm = combination(x);
			for(int i = 0; i < 10; i++){
				if( i == c[6] ){
					break;
				}
				if( x[i] > dp[i] ){
					p = nextCombination(p, 16);
					continue;
				}
				perm *= permutation(dp[i], x[i], mod);
				perm %= mod;
			}
			perm *= dp[c[6]];
			ans += perm;
			ans %= mod;
			p = nextCombination(p, 16);
		}
		writer.println(ans);
	}

	public static void main(String[] args) throws IOException {
		new D().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

}
