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.util.Scanner;

/**
 * Copyright (C) Untitled
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this code; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * EndCopyright:
 */

public class B
{
	static final int MOD = 1000000007;
	public static void main(String[] args)
	{
		int[][] C = new int[10][10];// [az][ta]
		C[0][0] = 1;
		for(int i = 1; i < C.length; ++i)
		{
			C[0][i] = 1;
			for(int j = 1; j <= i; ++j)
				C[j][i] = C[j][i - 1] + C[j - 1][i - 1];
		}

		Scanner stdin = new Scanner(System.in);
		int M = stdin.nextInt();

		long[] count = new long[10];
		int[] digs = new int[10];
		int temp = M;
		for(int i = 0; i < 10; ++i)
		{
			digs[i] = temp % 10;
			temp /= 10;
		}

		int carry = 0;
		for(int i = 9; i >= 0; --i)
		{
			if(digs[i] == 0)
				continue;
			else if(digs[i] < 4)
			{
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry] +=
							digs[i] * C[j][i] * (1 << j) * (1 << (3 * (i - j)));
				}
			}
			else if(digs[i] == 4)
			{
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry] +=
							digs[i] * C[j][i] * (1 << j) * (1 << (3 * (i - j)));
				}
				++carry;
			}
			else if(digs[i] < 7)
			{
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry] +=
							(digs[i] - 1) * C[j][i] * (1 << j)
									* (1 << (3 * (i - j)));
				}
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry + 1] +=
							C[j][i] * (1 << j) * (1 << (3 * (i - j)));
				}
			}
			else if(digs[i] == 7)
			{
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry] +=
							(digs[i] - 1) * C[j][i] * (1 << j)
									* (1 << (3 * (i - j)));
				}
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry + 1] +=
							C[j][i] * (1 << j) * (1 << (3 * (i - j)));
				}
				++carry;
			}
			else
			{
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry] +=
							(digs[i] - 2) * C[j][i] * (1 << j)
									* (1 << (3 * (i - j)));
				}
				for(int j = 0; j <= i; ++j)
				{
					count[j + carry + 1] +=
							2 * C[j][i] * (1 << j) * (1 << (3 * (i - j)));
				}
			}
		}
		int sth = 0;
		for(int i = 9; i >= 0; --i)
		{
			if(digs[i] == 4 || digs[i] == 7)
				++sth;
		}
		--count[0];
		++count[sth];

		//safe
// System.out.println(Arrays.toString(count));
		long result = 0;
		for(int i = 1; i < 10; ++i)
		{
			--count[i];
			int[] tmp = new int[]{0, 0, 0, 0, 0, 0};
			WH: while(true)
			{
				long r = count[i] + 1;
				for(int j = 0; j < 6; ++j)
				{
					r *= count[tmp[j]];
					r %= MOD;
					--count[tmp[j]];
				}
				for(int j = 0; j < 6; ++j)
				{
					++count[tmp[j]];
				}
				result += r;
				result %= MOD;
				for(int j = 0;; ++j)
				{
					if(j == 6)
						break WH;
					++tmp[j];
					if(tmp[0] + tmp[1] + tmp[2] + tmp[3] + tmp[4] + tmp[5] == i)
						for(int k = 0; k <= j; ++k)
							tmp[j] = 0;
					else
						break;
				}
			}

			++count[i];
		}
		System.out.println(result);
	}
}