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

public class D {
    public static void main(String[] args) throws IOException
    {
        new D().run();
    }

    InputReader in;
    PrintWriter out;

    public void run() throws IOException
    {
        in = new InputReader( System.in );
        out = new PrintWriter( System.out );
        solve();
        out.close();
    }

    final long MOD = (long)1e9 + 7;
    int len;
    int[] digit = new int[15];
    int[] count = new int[15];

    int[][][][] dp = new int[15][15][2][2];
    boolean [][][][] done = new boolean[15][15][2][2];

    int run(int p, int k, int z, int l)
    {
        if ( p < 0 ) return (z==0 && k == 0) ? 1 : 0;

        if ( done[p][k][z][l] ) return dp[p][k][z][l];
        done[p][k][z][l] = true;

        int ret = 0;
        if ( z == 1 ) ret = run( p-1, k, 1, 0 );
        for (int d = z; d < 10; d++)
        {
            if ( l == 1 && d > digit[p] ) break;
            if ( k == 0 && (d==4 || d==7) ) continue;
            ret += run( p-1, k - ((d==4 || d==7) ? 1 : 0), 0, (l==1 && d == digit[p]) ? 1 : 0 );
        }

        return dp[p][k][z][l] = ret;
    }

    long[][] C = new long[15][15];

    long func(int p, int r, int s)
    {
        if ( p > len ) return 0;
        if ( r == 0 )
        {
            long t = 0;
            for (int i=s+1; i<=len; i++) t = (t + count[i]) % MOD;
            return t;
        }
        else
        {
            long ret = func(p+1, r, s) % MOD, prod = 1;
            for (int i=1; i<=r; i++)
            {
                prod *= (long)(count[ p ] - i + 1);
                prod %= MOD;
                long x = (prod * func( p+1, r - i, s + p*i )) % MOD;
                x = (x * C[r][i]) % MOD;
                ret += x;
                ret %= MOD;
            }
            return ret;
        }
    }

    private void solve() throws IOException
    {
        int m = in.nextInt();

        len = 0;
        while ( m > 0 )
        {
            digit[ len++ ] = m % 10;
            m /= 10;
        }

        for (int i=0; i<=len; i++) count[i] = run( len-1, i, 1, 1 );
        //for (int i=0; i<=len; i++) out.println(i+" "+count[i]);

        for (int i=0; i<15; 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];
            }

        out.println( func(0, 6, 0) );
    }
}

class InputReader
{
    BufferedReader br;
    StringTokenizer st;

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

    public String next() throws IOException
    {
        while (st==null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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