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.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author c0der
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    int[][] C = new int[11][11];
    int[] digit = new int[ 10 ];
    int len;
    int[] choice = new int[11];

    int count(int K)
    {
        int ret = 0;

        for (int i=len-1; i>=0; i--)
        {
            for (int d=0; d<digit[i]; d++)
            {
                int k = K - (d==4 || d==7 ? 1 : 0);
                if ( k >= 0 && k<=i ) ret += C[i][k] * (1 << k) * (1 << (3*(i-k)));
            }
            if ( digit[i] == 4 || digit[i] == 7 ) K--;
        }
        if ( K == 0 ) ret++;

        return ret;
    }

    final long MOD = (int)1e9 + 7;
    long mod(long n)
    {
        return (n % MOD + MOD) % MOD;
    }

    long backtrack(int p, int r, int s)
    {
        if ( p > len ) return 0;
        if ( r == 0 )
        {
            long ways = 0;
            for (int i=s+1; i<=len; i++) ways += choice[i];
            return mod( ways );
        }
        else
        {
            long ret = backtrack(p+1, r, s), P = 1;
            for (int i=1; i<=r; i++)
            {
                P = mod( P * (choice[p] - i + 1) );
                ret = mod( ret + mod( C[r][i] * mod( P * backtrack( p+1, r-i, s + p*i ) ) ) );
            }
            return ret;
        }
    }

	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int m = in.nextInt();
        len = 0;
        while ( m > 0 )
        {
            digit[ len++ ] = m % 10;
            m /= 10;
        }
        for (int i=0; i<11; i++)
            for (int j=0; j<=i; j++)
            {
                if ( j==0 || j==i ) C[i][j] = 1;
                else C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        for (int i=0; i<=len; i++) choice[i] = count( i );
        choice[0]--;
        //for (int i=0; i<=len; i++) out.println( i+" "+choice[i] );
        out.println( backtrack( 0, 6, 0 ) );
	}
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader(InputStream in)
    {
        br = new BufferedReader(new InputStreamReader(in));
        st = null;
    }

    public String next()
    {
        while (st==null || !st.hasMoreTokens())
        {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }
}