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.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class main {
	public static long[] f;
	public static ArrayList<Integer> way = new ArrayList<Integer>();
	public static int[] marker = new int[11];
	public static long cur_ans = 0;
	public static long mod = 1000000007;
	public static long[] fact = new long[]{1, 1, 2, 6, 24, 120, 720};
	public static void find_ways(int idx, int rem, int prev) 
	{
		if (rem == 0) 
		{
			if(idx >= 0)
			{
				Arrays.fill(marker, 0);
				long temp_ans = 1;
				for (int x : way) 
				{
					temp_ans*=(f[x] - marker[x]);
					temp_ans%=mod;
					marker[x]++;
				}
				for (int j = way.size(); j < 6; j++) 
				{
					temp_ans*=(f[0] - marker[0]);
					temp_ans%=mod;
					marker[0]++;
				}
				long cons_mult = fact[6];
				cons_mult /= fact[6 - way.size()];
				for(int i= 0; i < way.size(); )
				{
					int j = i + 1;
					int cnt = 1;
					while(j < way.size() && way.get(i) == way.get(j)) { j++; cnt++; }
					cons_mult /= fact[cnt];
					i = j;
				}
				temp_ans *= cons_mult;
				temp_ans%=mod;
				cur_ans += temp_ans;
				cur_ans %= mod;
			}
			return;
		}
		for (int i = Math.min(prev, rem); i >= 1; i--) 
		{
			way.add(i);
			find_ways(idx - 1, rem - i, i);
			way.remove(way.size() - 1);
		}
	}
public static void solve() {
	int num = ip.nextInt();
	num++;
	String s = Integer.toString(num);
	int n = s.length();
	long[][] dp = new long[n + 1][n + 2];
	dp[0][n + 1] = 1;
	for (int i = n; i > 0; i--) {
		dp[0][i] = (8 * dp[0][i + 1]);
		for (int j = 1; j <= n; j++) dp[j][i] = (8 * dp[j][i + 1] + 2 * dp[j - 1][i + 1]);
	}
	f = new long[n + 1];
	long ans = 0;
	int cr;
	for (int i = 0; i <= n; i++) {
		cr = i;
		cur_ans = 0;
		for (int j = 1; j <= s.length() && cr >= 0; j++) {
			char c = s.charAt(j - 1);
			for (char k = '0'; k < c; k++) {
				if (k == '4' || k == '7') {
					if (cr != 0) cur_ans += dp[cr - 1][j + 1];
				} else cur_ans += dp[cr][j + 1];
			}
			if (c == '4' || c == '7') cr--;
		}
		f[i] = cur_ans;
	}
	f[0]--;
	// find_ways(6, 5, 5);
	cur_ans = 0;;
	for(int i = 1; i <= n; i++)
	{
		find_ways(6, i - 1, i - 1);
		ans += (f[i]*cur_ans);
		ans %= mod;
	}
	out.println(ans);
}
public static void main(String[] arg) {
	out = new PrintWriter(new BufferedOutputStream(System.out));
	ip = new FastReader();
	solve();
	out.close();
}
public static FastReader ip;
public static PrintWriter out;

public static class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;
	}
}
}