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

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;
		
		Digits D = new Digits(M);
		int N = D.count(), X = D.top();
		
		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) {
			Digits D = new Digits(i);
			if (D.sum() < 10) {
				long [] Z2 = copyOf(Z, 10);
				long V = 1;
				for (int j = 0; j < 6; ++j) {
					V = mod(V * Z2[D.get(j)]);
					--Z2[D.get(j)];
				}
				Y[D.sum()] = mod(Y[D.sum()] + 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);
	}

	class Digits {
		final int [] D;
		final int cnt, sum;
		
		Digits(long N) {
			int cnt = 0, sum = 0;
			long M = N;

			while (M > 0) {
				++cnt; sum += M % 10; M /= 10;
			}
			
			D = new int [cnt];
			for (int i = 0; i < cnt; ++i, N /= 10)
				D[i] = (int) N % 10;
			
			this.cnt = cnt;
			this.sum = sum;
		}
		
		int get(int i) { return i < cnt ? D[i] : 0; }
		int top() { return top(0) ; }
		int top(int i) { return i == 0 && cnt == 0 ? 0 : D[cnt-1-i] ; }
		int count() { return count(true); }
		int count(boolean zero) { return zero && cnt == 0 ? 1 : cnt; } 
		int sum() { return sum; }
		
		public String toString() {
			return Arrays.toString(D);
		}
	}
	
	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();
	}	
}