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.util.Arrays.*;

import java.io.*;
import java.lang.reflect.*;

public class B {

	final int MOD = (int)1e9 + 7;
	final double eps = 1e-12;
	final int INF = (int)1e9;
	
	int [] L = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2 };
	int [] U = { 1, 2, 3, 4, 4, 5, 6, 6, 7, 8 };
	
	long Z(int k, long M) {
		if (k < 0) 
			return 0;
		
		int [] D = digits(M);
		int N = D.length, X = D[0];
		
		if (N < k)
			return 0;
		else if (N == 1)
			return k == 0 ? U[X] : L[X];
		else {
			long res = 0;
			if (N > k)
				res += U[X-1] * bin[N-1][k] * pow(2, k) * pow(8, N-1-k);
			if (k > 0)
				res += L[X-1] * bin[N-1][k-1] * pow(2, k-1) * pow(8, N-k);
			res += Z(X == 4 || X == 7 ? k-1 : k, M % pow(10, N-1));			
			return res;
		}
	}
	
	public B () {
		long M = sc.nextInt();
		
		bin(); 
		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 = digsum(i);
			if (s < 10) {
				int [] D = digits(i, 6);
				long [] Z2 = copyOf(Z, 10);
				long V = 1;
				for (int j = 0; j < 6; ++j) {
					V = mod(V * Z2[D[j]]);
					--Z2[D[j]];
				}
				Y[s] = mod(Y[s] + V);
			}
		}
		
		long [] SY = new long [10];
		for (int i = 1; i < 10; ++i)
			SY[i] = mod(SY[i-1] + Y[i-1]);
		
		long res = 0;
		for (int i = 1; i < 10; ++i)
			res = mod(res + Z[i] * SY[i]);
		
		exit(res);
	}

	int digcount(long N) {
		if (N == 0)
			return 1;
		else {
			int res = 0;
			while (N > 0) {
				N /= 10;
				++res;
			}
			return res;
		}
	}
	
	int [] digits(long N) { // big endian!
		return digits(N, digcount(N));
	}
	
	int [] digits(long N, int sz) { // big endian! may be cut, or have leading zeroes
		int [] res = new int [sz];
		for (int i = sz-1; i >= 0 && N > 0; --i, N /= 10)
			res[i] = (int) N % 10;
		return res;
	}
	
	int digsum(long N) {
		int res = 0;
		while (N > 0) {
			res += N % 10;
			N /= 10;
		}
		return res;		
	}
	
	long mod(long x) {
		return ((x % MOD) + MOD) % MOD;
	}

	long pow (long x, long y) {
		return (long)Math.pow(x, y);
	}
	
	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();
	}	
}