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 static java.lang.Math.*; 

import java.io.*; 
import java.util.*; 
import java.math.*;

public class Template {
	BufferedReader in; 
	PrintWriter out;
	StringTokenizer st; 

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

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

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

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

	int len;
	int[] a; 
	long[][][] dp = new long[20][2][20];
	long mod = 1000000007;

	long calc(int i, int sp, int sum) {
		if (sum < 0) return 0;
		long cur = dp[i][sp][sum];
		if (i==len) {
			if (sum == 0) return 1; 
			return 0; 
		}

		if (cur != -1) return cur;
		cur=0;

		for (int j=0; j<10; j++) {
			if (sp == 1 && j > a[i]) break;
			if (j==4 || j == 7) {
				cur+=calc(i+1, (j==a[i] && sp == 1 ? 1 : 0), sum - 1);
			} else {
				cur+=calc(i+1, (j==a[i] && sp == 1 ? 1 : 0), sum);
			}
		}
		dp[i][sp][sum] = cur; 
		return cur; 
	}


	long power(long a, long b) {
		if (b==0) return 1; 
		if (b==1) return a;

		if (b % 2 == 0) {
			long d = power(a, b/2);
			return (d*d) % mod; 
		} else {
			return (a*power(a, b-1)) % mod; 
		}
	}

	long cnk(long n, long k) {
		long ret = 1;
		for (int i=(int)(n-k+1); i<=n; i++) ret = (ret * i) % mod; 

		for (int i=2; i<=k; i++) {
			long ri = power((long)i, mod - 2);
			ret = (ret * ri) % mod; 
		}

		return ret; 
	}

	long fact(int n) {
		long ret = 1; 
		for (int i=2; i<=n; i++) ret = (ret * i) % mod; 
		return ret; 
	}


	public void run() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Long start = System.currentTimeMillis();

		int m = nextInt(); 

		int x = m; 
		a = new int[122]; 

		while (x > 0) {
			a[len++] = x % 10;
			x/=10; 
		}

		for (int i=0; i<len/2; i++) {
			int w = a[i]; 
			a[i] = a[len - i - 1]; 
			a[len - i - 1] = w; 
		}


		for (long[][] f : dp)
			for (long[] g : f) Arrays.fill(g, -1);

		for (int i=0; i<=len; i++) {
			calc(0, 1, i);
		}

		dp[0][1][0] = (dp[0][1][0] - 1 + mod) % mod;

		long[][][] d = new long[len+1][7][len+1];
		d[0][0][0] = 1; 

		for (int i=0; i<len; i++) {
			for (int j=0; j<=6; j++) {
				for (int sum=0; sum<=len; sum++) if (d[i][j][sum] > 0) {
					long now = d[i][j][sum];

					for (int k=0; k<=6 - j; k++) {
						if (sum + i * k > len) break;
						int nsum = sum + i*k;
						d[i+1][j+k][nsum] = d[i+1][j+k][nsum] + (now * (((cnk(dp[0][1][i], k)*cnk(6-j, k)) % mod * fact(k)) % mod)) % mod;
						d[i+1][j+k][nsum] %= mod; 
					}
				}
			}
		}

		long ans=0;

		for (int sum=0; sum<len; sum++) {
			long cur=0;
			for (int i=sum+1; i<=len; i++) cur+=dp[0][1][i];

			ans = (ans + (cur * d[len][6][sum]) % mod) % mod;
		}

		out.println(ans);


		
		Long end = System.currentTimeMillis();

		//System.out.println((end - start) / 1000.0);
		out.close(); 
	}
	
	class Pair implements Comparable<Pair> {
		long f,s; 
		public Pair(long f, long s) {
			this.f=f; 
			this.s=s;
		}

		public int compareTo(Pair o) {
			return sg(f - o.f); 
		}

		public int sg(long x) {
			if (x > 0) return 1; 
			if (x < 0) return -1;
			return 0;
		}
	}

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