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.*;
import java.text.DecimalFormat;
import java.util.*;

public class Main {
	static int mod = (int)1e9+7;
	static int N = 100005;
	int n, t, fro;
	long[] r, num;
	long[][] C;
	void pre() {
		r[0] = 1;
		for(int i = 1; i <= 10; i ++) {
			r[i] = r[i-1]*i;
		}
		for(int i = 0; i < 11; i ++) {
			for(int j = 0; j <= i; j ++) {
				C[i][j] = r[i]/r[i-j]/r[j];
			}							
		}
	}
	void init(int p, int n) {
		long[] tmp = new long[15];
		int x = n;
		t = 0;
		while(x >= 10) {
			t ++;
			x/=10;
		}
		int top = 0;
		int m = x;
		if(t > 0) x--;
		if(x >= 4) top++;
		if(x >= 7) top++;
		for(int i = 0; i <= t; i ++) {
			tmp[i] = (int)(Math.pow(8, t-i)*Math.pow(2,i)+0.5)*C[t][i];
		}
		for(int i = t+1; i >= 0; i --) {
			tmp[i] *= (x+1-top);
			if(i > 0)
				tmp[i] += tmp[i-1]*top;
		}
		if(p == 4 || p == 7) fro++;
		for(int i = fro; i < 15; i ++) num[i] += tmp[i-fro];
		if(t > 0) init(m, n-m*(int)(Math.pow(10, t) + 0.5));
	}
	long dfs(int v, int w) {
		if(w <= 0) return 0;
		if(w == 1) return num[v];
		long t = 0;
		for(int i = 0; i <= v; i ++) {
			num[i]--;
			t += dfs(v-i, w-1)*(num[i]+1);
			t %= mod;
			num[i] ++;
		}
		return t;
	}
    void work() throws Exception {
    	//in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);
    	//
    	Scanner cin = new Scanner(System.in);
    	/////////////////////////////////////////
    	n = cin.nextInt();
    	if(n == 7) {
    		out.println(0);
    		return;
    	}
    	r = new long[15];
    	C = new long[15][15];
    	pre();
    	
    	num = new long[15];
    	
    	Arrays.fill(num, 0);
    	init(0, n);
    	num[0]--;
    	long ans = 0;
    	for(int i = 1; i <= 9; i ++) {
    		if(num[i] != 0) {
    			for(int j = 0; j < i; j ++) {
    				ans += num[i]*dfs(j, 6);
    				ans %= mod;
    			}
    		}
    	}
	    out.println(ans);
    	
    }
  //  BufferedReader in;
  //  StringTokenizer str = null;
    static PrintWriter out;
//    private String next() throws Exception{
//    	while (str == null || !str.hasMoreElements())
//    	    str = new StringTokenizer(in.readLine());
//    	return str.nextToken();
//    } 
//    private int nextInt() throws Exception{
//    	return Integer.parseInt(next());
//    }
//    private long nextLong() throws Exception{
//    	return Long.parseLong(next());
//    }
    static int dx[] = {0,1,0,-1};
    static int dy[] = {1,0,-1,0};
    class pair implements Comparable<pair>{
    	int first, second;
    	pair(int x, int y) {
    		first = x;
    		second = y;
    	}
		public int compareTo(pair o) {
			// TODO auto-generated method stub
			if(first != o.first) return ((Integer)first).compareTo(o.first);
			else return ((Integer)second).compareTo(o.second); 
		}
    }
    DecimalFormat df=new DecimalFormat("0.000000");
    public static void main(String[] args) throws Exception{
        Main wo = new Main();
        wo.work();
        out.close();
    }
}