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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Round157B {

	public static long mod = (long)1e9+7;
	
	public static void solve() {
		long m = s.nextLong();
		M = Long.toString(m);
		long[] sums = new long[10];
		for(int i = 1; i <= 9; i++) {
			dp = new long[10][i + 1][2];
			for(int j = 0; j < 10; j++) {
				for(int k = 0; k <= i; k++) {
					for(int l = 0; l < 2; l++) {
						dp[j][k][l] = -1;
					}
				}
			}
			sums[i] = Recur(0, 0, 1);
		}
		long[] suffix_sum = new long[10];
		suffix_sum[9] = sums[9];
		for(int i = 8; i >= 0; i--) {
			suffix_sum[i] = suffix_sum[i + 1] + sums[i];
		}
		sums[0] = m - suffix_sum[0];
		suffix_sum[0] = m;
		long ans = 0;
//		for(int i = 1; i < 10; i++) {
//			long me = sums[i];
//			long other = m - suffix_sum[i];
//			if(other < 6) {
//				continue;
//			}else {
//				long tempans = 1;
//				for(long j = other; j >= other - 5; j--) {
//					tempans = (tempans * j)%mod;
//				}
//				tempans = (tempans * me)%mod;
//				ans = ans + tempans;
//				if(ans >= mod) ans -= mod;
//			}
//		}
		long[][] dp2 = new long[10][10];
		for(int i = 0; i < 10; i++) {
			dp2[i][0] = 1;
			long val = sums[i];
			long tempans = 1;
			for(int j = 1; j < 10; j++) {
				tempans = (val * tempans)%mod;
				dp2[i][j] = tempans;
				val--;
			}
		}
		for(int first = 1; first < 10; first++) {
//			int vals = 0;
			int[] count = new int[10];
			for(int second = 0; second < first; second++) {
				for(int third = 0; second + third < first; third++) {
					for(int fourth = 0; second + third + fourth < first; fourth++) {
						for(int fifth = 0; second + third + fourth + fifth < first; fifth++) {
							for(int sixth = 0; second + third + fourth + fifth + sixth < first; sixth++) {
								for(int seventh = 0; second + third + fourth + fifth + sixth + seventh < first; seventh++) {
//									vals++;
									count[second]++;
									count[third]++;
									count[fourth]++;
									count[sixth]++;
									count[fifth]++;
									count[seventh]++;
									long tempans = sums[first];
									for(int i = 0; i < first; i++) {
										tempans = tempans * dp2[i][count[i]];
										tempans %= mod;
									}
									ans += tempans;
									if(ans >= mod) ans -= mod;
									count[second]--;
									count[third]--;
									count[fourth]--;
									count[sixth]--;
									count[fifth]--;
									count[seventh]--;
								}
							}
						}
					}
				}
			}
//			out.println(vals);
		}
		out.println(ans);
	}
		
	public static long[][][] dp; 
	public static String M;
	
	public static long Recur(int pos, int count, int f) {
		if(pos == M.length()) {
			if(count == 0) {
				return 0;
			}
			if(count == dp[0].length - 1) {
				return 1;
			}else {
				return 0;
			}
		}
		if(count > dp[0].length - 1) {
			return 0;
		}
		if(dp[pos][count][f] != -1) {
			return dp[pos][count][f];
		}
		int lmtS = 0, lmtE;
		if(f == 1) {
			lmtE = M.charAt(pos) - '0';
		}else {
			lmtE = 9;
		}
		long ans = 0;
		for(int i = lmtS; i <= lmtE; i++) {
			int new_count = count + ((i == 4 || i == 7) ? 1 : 0);
			int newf = (f == 1 && i == lmtE ? 1 : 0);
			ans += Recur(pos + 1, new_count, newf);
		}
		return dp[pos][count][f] = ans;
	}
	
	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}
	
	public static class Triplet {
		long gcd;
		long x;
		long y;

		Triplet(long gcd, long x, long y) {
			this.gcd = gcd;
			this.x = x;
			this.y = y;
		}
	}

	public static Triplet ExtendedEuclideanAlgo(long a, long b) {
		if (a == 0) {
			return new Triplet(b, 0, 1);
		}
		Triplet ans = ExtendedEuclideanAlgo(b % a, a);
		long x = ans.y - (b / a) * ans.x;
		long y = ans.x;
		return new Triplet(ans.gcd, x, y);
	}

	public static long ModInverse(long a, long m) {
		Triplet ans = ExtendedEuclideanAlgo(a, m);
		if (ans.gcd != 1) {
			//System.out.println("Multiplicative inverse doesnot exist");
			return -1;
		} else {
			//m is added to handle negative x
			long result = (ans.x % m + m) % m;
			return result;
		}
	}

	public static FastReader s;
	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;
		}
	}

	
}