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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.close();
		in.close();
	}

	String s;
	int n;
	long[][][] cantidad;
	long MOD = 1000000007;

	private Object solve() throws IOException {
		s = in.readLine();
		n = s.length();
		cantidad = new long[n + 1][2][10];
		for (long[][] iss : cantidad)
			for (long[] is : iss)
				Arrays.fill(is, -1);

		for (int a = 0; a <= 9; a++)
			solve(0, false, a);
		cantidad[0][0][0]--;
		
		long ret = 0;
		for (int me = 1; me <= 9; me++) {
			long count_me = cantidad[0][0][me]--;
			for (int other = 0; other < me; other++) {
				long count_other = ways(0, other);
				long aux = (count_me * count_other) % MOD;
				ret = (ret + aux) % MOD;
			}
			cantidad[0][0][me]++;
		}
		return ret;
	}

	private long ways(int index, int left) {
		if(index==6 )
			return (left==0? 1 : 0);
		long ret = 0;
		for (int cant = 0; cant <= left; cant++)
			if (cantidad[0][0][cant] > 0) {
				long aux = cantidad[0][0][cant]--;
				long a = ways(index + 1, left - cant);
				aux = (aux * a) % MOD;
				ret = (ret + aux) % MOD;
				
				cantidad[0][0][cant]++;
			}
		return ret;
	}

	private long solve(int next, boolean free, int magicos) {
		if (next == n)
			return magicos == 0 ? 1 : 0;
		if (magicos < 0)
			return 0;
		int beta = (free ? 1 : 0);
		if (cantidad[next][beta][magicos] != -1)
			return cantidad[next][beta][magicos];

		cantidad[next][beta][magicos] = 0;

		int digit = s.charAt(next) - '0';
		for (int i = 0; i < digit; i++)
			if (i == 4 || i == 7) {
				cantidad[next][beta][magicos] += solve(next + 1, true,
						magicos - 1);
			} else {
				cantidad[next][beta][magicos] += solve(next + 1, true, magicos);
			}

		if (digit == 4 || digit == 7) {
			cantidad[next][beta][magicos] += solve(next + 1, free, magicos - 1);
		} else {
			cantidad[next][beta][magicos] += solve(next + 1, free, magicos);
		}
		if (free) {
			for (int i = digit + 1; i <= 9; i++)
				if (i == 4 || i == 7) {
					cantidad[next][beta][magicos] += solve(next + 1, true,
							magicos - 1);
				} else {
					cantidad[next][beta][magicos] += solve(next + 1, true,
							magicos);
				}
		}

		return cantidad[next][beta][magicos];
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}
}