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 static java.util.Arrays.*;
import static java.util.Collections.*;
import java.io.*;
import java.math.*;
import java.util.*;

@SuppressWarnings("unused")
public class B {
	static final long MOD = 1000 * 1000 * 1000 + 7;
	static char[] m;
	static long[] cnt, F;
	static long[][][][] dp1;
	static long[][][] dp2;

	public static void main(String[] args) throws Exception {
		dp1 = new long[20][20][5][5];
		dp2 = new long[20][200][20];
		for (long[][][] a : dp1) {
			for (long[][] b : a) {
				for (long[] c : b) {
					fill(c, -1);
				}
			}
		}
		for (long[][] a : dp2) {
			for (long[] b : a) {
				fill(b, -1);
			}
		}
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		m = br.readLine().toCharArray();
		cnt = new long[10];
		for (int i = 0; i < 10; i++) {
			cnt[i] = go1(m.length, i, 0, 0);
		}
		F = new long[10];
		F[0] = 1;
		for (int i = 1; i < 10; i++) {
			F[i] = i * F[i - 1];
		}
		System.out.println((go2(0, 0, 0) * F[6]) % MOD);
	}

	static long go2(int index, int k, int done) {
		if (index >= 10) {
			return done == 7 ? 1 : 0;
		}
		if (dp2[index][k][done] != -1) {
			return dp2[index][k][done];
		}
		if (done == 6) {
			long ans = 0;
			for (int i = k + 1; i < 10; i++) {
				ans += cnt[i] * go2(10, k, 7);
				ans %= MOD;
			}
			return dp2[index][k][done] = ans;
		} else {
			int rem = 6 - done;
			long ans = 0;
			for (int i = 0; i <= rem && i <= cnt[index]; i++) {
				ans += nck(cnt[index], i) * go2(index + 1, k + i * index, done + i);
				ans %= MOD;
			}
			return dp2[index][k][done] = ans;
		}
	}

	static long nck(long n, int k) {
		long ans = 1;
		for (int i = 0; i < k; i++) {
			ans *= n - i;
			ans %= MOD;
		}
		ans *= modpow(F[k], MOD - 2, MOD);
		ans %= MOD;
		return ans;
	}

	static long modpow(long n, long p, long MOD) {
		long ans = 1;
		while (p > 0) {
			if ((p & 1) != 0) {
				ans *= n;
				ans %= MOD;
			}
			p >>= 1;
			n *= n;
			n %= MOD;
		}
		return ans;
	}

	static long go1(int size, int k, int cmp, int nonzero) {
		if (size == 0) {
			return (k == 0 && cmp <= 0 && nonzero == 1) ? 1 : 0;
		}
		if (k < 0) {
			return 0;
		}
		if (dp1[size][k][cmp + 1][nonzero] != -1) {
			return dp1[size][k][cmp + 1][nonzero];
		}
		long ans = 0;
		for (int i = 0; i < 10; i++) {
			if (m[size - 1] - '0' > i) {
				ans += go1(size - 1, k - (i == 4 || i == 7 ? 1 : 0), -1, i == 0 ? nonzero : 1);
			} else if (m[size - 1] - '0' < i) {
				ans += go1(size - 1, k - (i == 4 || i == 7 ? 1 : 0), +1, i == 0 ? nonzero : 1);
			} else {
				ans += go1(size - 1, k - (i == 4 || i == 7 ? 1 : 0), cmp, i == 0 ? nonzero : 1);
			}
			ans %= MOD;
		}
		return dp1[size][k][cmp + 1][nonzero] = ans;
	}
}