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 java.io.*;
import java.lang.reflect.*;

public class B {

	final long MOD = (long)1e9 + 7;
	final double eps = 1e-12;
	final int INF = (int)1e9;
	
	int [] L = { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2 };
	int [] U = { 0, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8 };
	
	char [] D(long M) {
		char [] D = ("" + M).toCharArray();
		for (int i = 0; i < D.length; ++i)
			D[i] -= '0';
		return D;
	}
	
	long z(int k, long M) {
		if (k < 0) return 0;
		
		char [] D = D(M);
		int N = D.length; 
		int X = D[0];
		
		if (N < k)
			return 0;
		else if (N == 1)
			return k == 0 ? U[X+1] : L[X+1];
		else {
			long res = 0;
			if (N > k)
				res += U[X] * bin[N-1][k] * (1 << k) * (1 << (3*(N-k-1)));
			if (k > 0)
				res += L[X] * bin[N-1][k-1] * (1 << (k-1)) * (1 << (3*(N-k)));
			
			res += z((X == 4 || X == 7) ? (k-1) : k, M % (int)pow(10, N-1));			
			return res;
		}
	}
	
	int sum(long N) {
		int res = 0;
		while (N > 0) {
			res += N%10;
			N /= 10;
		}
		return res;
	}
	
	int [] dig(long N) {
		int [] res = new int [6];
		for (int i = 0; i < 6; ++i) {
			res[i] = (int)N%10;
			N /= 10;
		}
		return res;
	}
	
	public B () {
		bin();
		long M = sc.nextInt();
		
		long [] Z = new long [10];
		for (int i = 0; i < 10; ++i)
			Z[i] = z(i, M);
		--Z[0];
		
		long [] Y = new long [10];		
		for (int i = 0; i <= 999999; ++i) {
			int S = sum(i);
			if (S < 10) {
				long [] ZZ = copyOf(Z, 10);
				int [] D = dig(i);
				long V = 1;
				for (int j = 0; j < 6; ++j) {
					V = mod(V * ZZ[D[j]]);
					--ZZ[D[j]];
				}
				Y[S] = mod(Y[S] + V);
			}
		}
		
		long [] YY = new long [11];
		for (int i = 1; i <= 10; ++i)
			YY[i] = mod(YY[i-1] + Y[i-1]);
		
		long res = 0;
		for (int i = 1; i < 10; ++i)
			res = mod(res + Z[i] * YY[i]);
		
		exit(res);
	}

	long mod(long x) {
		return ((x % MOD) + MOD) % MOD;
	}

	int N = 10, K = 10;	
	long [][] bin = new long [N][K];
	void bin() {
		for (int n = 0; n < N; ++n) {
			bin[n][0] = 1;
			for (int k = 1; k < K && k <= n; ++k)
				bin[n][k] = bin[n-1][k] + bin[n-1][k-1];
		}		
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	static MyScanner sc;
	
	static class MyScanner {
		public String next() {
			newLine();
			return line[index++];
		}
		
		public char nextChar() {
			return next().charAt(0);
		}
				
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		
		public String nextLine() {
			line = null;
			return readLine();
		}
		
		public String [] nextStrings() {
			line = null;
			return readLine().split(" ");
		}
		
		public char [] nextChars() {
			return next().toCharArray();
		}

		public Integer [] nextInts() {
			String [] L = nextStrings();
			Integer [] res = new Integer [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}	
		
		public Long [] nextLongs() {
			String [] L = nextStrings();
			Long [] res = new Long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		public Double [] nextDoubles() {
			String [] L = nextStrings();
			Double [] res = new Double [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Double.parseDouble(L[i]);
			return res;
		}

		//////////////////////////////////////////////
		
		private boolean eol() {
			return index == line.length;
		}

		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private final BufferedReader r;

		MyScanner () {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		
		private String [] line;
		private int index;

		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}		
	}
	
	static void print (Object o, Object... a) {
		pw.println(build(o, a));
	}

	static void exit (Object o, Object... a) {
		print(o, a);
		exit();
	}

	static void exit () {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	
	void NO() {
		throw new Error("NO!");
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	static String build(Object... a) {
		StringBuilder b = new StringBuilder();
		for (Object o : a)
			append(b, o);
		return b.toString().trim();		
	}
	
	static void append(StringBuilder b, Object o) {
		if (o.getClass().isArray()) {
			int L = Array.getLength(o);
			for (int i = 0; i < L; ++i)
				append(b, Array.get(o, i));
		} else if (o instanceof Iterable<?>) {
			for (Object p : (Iterable<?>)o)
				append(b, p);
		} else
			b.append(" ").append(o);		
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	public static void main(String[] args) {
		sc = new MyScanner ();
		new B();
		exit();
	}

	static void start() {
		t = millis();
	}

	static PrintWriter pw = new PrintWriter(System.out);
	
	static long t;
	
	static long millis() {
		return System.currentTimeMillis();
	}	
}