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.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;


public class B {
	
	static StringTokenizer st;
	static BufferedReader in;
	static String t;
	static Map<String, Long> map = new HashMap<String, Long>();
	static long mod = (long) (1e9+7);
	static int[]a;
	static long[]cnt;
	static long p;
	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int m = nextInt();
		t = m+"";
		while (t.length() != 10)
			t = "0"+t;
		cnt = new long[11];
		for (int mask = 0; mask < Math.pow(3, 10); mask++) {
			String s = Long.toString(mask, 3);
			while (s.length() != 10)
				s = "0"+s;
			int bit = 0;
			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i)=='1' || s.charAt(i)=='2')
					bit++;
			}
			long b = calc(s, 0, false);
			cnt[bit] += b;
		}
		long ans = 0;
		cnt[0]--;
		a = new int[8];
		for (int i = 1; i <= 10; i++) {
			for (int j = 0; j < i; j++) {
				ans = (ans+solve(j)*cnt[i] % mod) % mod;
			}
		}
		System.out.println(ans);
		
		pw.close();
	}
	
	private static long solve(int n) {
		p = 0;
		go(n, 1);
		return p;
	}

	private static void go(int n, int ind) {
		if (ind==6) {
			a[ind] = n;
			long pp = 1;
			int[]cnt2 = new int[11];
			for (int i = 1; i <= 6; i++) {
				cnt2[a[i]]++;
			}
			for (int i = 0; i <= 10; i++) {
				pp = (pp * P_n_k(cnt2[i], cnt[i])) % mod;
			}
			p += pp;
			return;
		}
		for (int i = 0; i <= n; i++) {
			a[ind] = i;
			go(n-i, ind+1);
		}
	}

	private static long P_n_k(int k, long n) {
		if (k > n)
			return 0;
		long res = 1;
		for (long i = n-k+1; i <= n; i++) {
			res = (res * i) % mod;
		}
		return res;
	}

	private static long calc(String mask, int ind, boolean f) {
		int w = 0;
		if (f)
			w = 1;
		String r = mask+" "+w;
		if (mask.length()==0) {
			return 1;
		}
		if (map.containsKey(r))
			return map.get(r);
		if (mask.charAt(0) != '0') {
			if (f)
				return calc(mask.substring(1), ind+1, f);
			else {
				char q = '4';
				if (mask.charAt(0)=='2')
					q = '7';
				if (q > t.charAt(ind))
					return 0;
				else {
					if (q==t.charAt(ind))
						return calc(mask.substring(1), ind+1, f);
					return calc(mask.substring(1), ind+1, true);
				}
			}
		}
		long res = 0;
		if (f) {
			for (int i = 0; i <= 9; i++) {
				if (i==4 || i==7)
					continue;
				res += calc(mask.substring(1), ind+1, f);
			}
		}
		else {
			for (int i = 0; i <= 9; i++) {
				if (i==4 || i==7)
					continue;
				if (i < t.charAt(ind)-48) {
					res += calc(mask.substring(1), ind+1, true);
				}
				else if (i==t.charAt(ind)-48)
					res += calc(mask.substring(1), ind+1, f);
			}
		}
		map.put(r, res);
		return res;
	}
	private static int nextInt() throws IOException{
		return Integer.parseInt(next());
	}
	
	private static long nextLong() throws IOException{
		return Long.parseLong(next());
	}
	
	private static double nextDouble() throws IOException{
		return Double.parseDouble(next());
	}
	
	private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}