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

public class D {
    static int[] a;
    static long[] total = new long[12];

    static long[][][] dp = new long[12][12][2];
    static long[][][] dp2 = new long[12][12][12];

    public static void main(String[] args) throws IOException {
        fact[0]=1;
        for(int i = 1 ; i<8;i++ )
            fact[i] = fact[i-1]*i;
        InputReader in = new InputReader();
        int m = in.nextInt();
        String xx = m + "";
        a = new int[xx.length()];
        for (int i = 0; i < xx.length(); i++)
            a[i] = xx.charAt(i) - '0';
        for (int i = 0; i < 12; i++)
            for (int j = 0; j < 12; j++) {
                dp[i][j][0] = dp[i][j][1] = -1;
                Arrays.fill(dp2[i][j], -1);
            }
        for (int i = 0; i <= 9; i++)
            total[i] = go(0, i, 0);
        total[0]--;
        long res = 0;
        for (int i = 1; i < 12; i++)
            res = (res + total[i]*go2(6, i,i-1)) % mod;
        System.out.println(res);
    }

    static long mod = 1000000007;

    public static long perm(long l, int x) {
        if (l < x)
            return 0;
        long res = 1;
        for (int i = 0; i < x; i++)
            res = (res * (l - i)) % mod;
        return res;
    }

    public static long go2(int left, int sum,int lky) {
        if(left==0)return sum>0?1:0;
        if(sum<=0)return 0;
        if(lky<0)return 0;
        if(dp2[left][sum][lky]!=-1)return dp2[left][sum][lky];
        long res = 0;
        for(int x = 0 ; x<=left;x++)
            res = (res+((comb(left,x)*perm(total[lky],x))%mod)*go2(left-x,sum-x*lky,lky-1))%mod;
        return dp2[left][sum][lky]=res;
    }
    static long[] fact= new long[8];
    public static long comb(int left, int x) {
        long res = perm(left, x);
        return res/fact[x];
    }

    public static long go(int i, int lky, int sm) {
        if (lky < 0)
            return 0;
        if (i == a.length)
            return lky == 0 ? 1 : 0;
        if (dp[i][lky][sm] != -1)
            return dp[i][lky][sm];
        long res = 0;
        if (sm == 1)
            for (int x = 0; x < 10; x++)
                res += go(i + 1, lky - ((x == 4 || x == 7) ? 1 : 0), sm);
        else
            for (int x = 0; x <= a[i]; x++)
                res += go(i + 1, lky - ((x == 4 || x == 7) ? 1 : 0),
                        x < a[i] ? 1 : 0);
        return dp[i][lky][sm] = res;
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer(in.readLine());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

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

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

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}