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



public class B {
    private static final int mod = (int)1e9+7;
    
    int m;
    int[] num = new int[10];
    int[][][] dp = new int[10][2][10];
    
    long comb(int n, int r) {
        BigInteger b = BigInteger.ONE;
        for(int i = 0; i < r; i++) {
            b = b.multiply(BigInteger.valueOf(n - i)).divide(BigInteger.valueOf(i + 1));
        }
        return b.mod(BigInteger.valueOf(mod)).longValue();
    }
    
    long fact(int n) {
        long res = 1;
        for(int i = 1; i <= n; i++) {
            res = res * i % mod;
        }
        return res;
    }
    
    int rec(int idx, int upper, int cnt) {
        if(idx == dp.length || cnt == -1) { return cnt == 0 ? 1 : 0; }
        
        if(dp[idx][upper][cnt] != -1) {
            return dp[idx][upper][cnt];
        }
        
        int res = 0;
        
        for(int i = 0; i < 10; i++) {
            if(upper == 1 && i > num[idx]) {
                break;
            }
            
            res += rec(idx + 1, upper == 1 && i == num[idx] ? 1 : 0, cnt - (i == 4 || i == 7 ? 1 : 0));
        }
//      IOFast.out.println(idx + " " + upper  + " " + cnt + " " + res);
        return dp[idx][upper][cnt] = res;
    }

    final int[] count = new int[10];
    long[][] dp2 = new long[6][10];
    long rec2(int idx, int rest, int cnt) {
        if(rest == 0 && cnt >= 0) return 1;
        if(cnt < 0 || rest < 0 || idx == 10) return 0;
//      if(idx == 1 ) IOFast.out.println(idx + " " + rest + " " + cnt + " " + 22);
//      if(dp2[idx][cnt] != -1) { return dp2[idx][cnt]; }
        long res = 0;
        for(int i = 0; i < 10; i++) {
            res += rec2(idx + 1, rest - i, cnt - i * idx) * comb(count[idx], i) % mod * fact(i) % mod * comb(rest, i) % mod;
//          if(idx == 0 && i == 6) IOFast.out.println(i + " " + count[idx] + " " + comb(count[idx], i) % mod * fact(i));
        }
//      return dp2[idx][cnt] = res;
        return res;
    }
    
    public void run() throws IOException {
        for(int[][] d : dp) for(int[] p : d) Arrays.fill(p, -1);
        for(long[] d : dp2) Arrays.fill(d, -1);
        m = IOFast.nextInt();
        
        for(int i = num.length - 1, j = m; i >= 0; i--, j /= 10) {
            num[i] = j % 10;
//          IOFast.out.println(num[i]);
        }
        
        for(int i = 0; i < 10; i++) {
            count[i] = (i == 0 ? -1 : 0) + rec(0, 1, i);
//          IOFast.out.println(i + " " + count[i]);
        }
        
        long res = 0;
        for(int i = 1; i < count.length; i++) {
//          res += count[i] * comb(count[i-1], 6) % mod * fact(6) % mod;
            res += count[i] * rec2(0, 6, i - 1) % mod;
        }
        
        IOFast.out.println(res % mod);
    }
    
    public static void main(String[] args) throws IOException {
//      IOFast.setFileIO("input.txt", "output.txt");
        new B().run();
        IOFast.out.flush();
    }



    static public class IOFast {
        private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        private static PrintWriter out = new PrintWriter(System.out);

        static void setFileIO(String ins, String outs) throws IOException {
            try {
                in = new BufferedReader(new FileReader(ins));
                out = new PrintWriter(new FileWriter(outs));
            }
            catch(IOException e) {
                System.err.println(e);
                throw e;
            }
        }

        //      private static final int BUFFER_SIZE = 50 * 200000;
        private static int pos, readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static final StringBuilder buf = new StringBuilder();
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];

        static {
            for(int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
        }

        static boolean endInput;

        private static int read() throws IOException {
            if(readLen == -1) {
                return -1;
            }

            if(pos >= readLen) {
                readLen = in.read(buffer);
                pos = 0;

                if(readLen <= 0) {
                    return -1;
                }
            }

            return buffer[pos++];
        }

        private static int nextInt() throws IOException {
            boolean plus = false;
            int ret = 0;
            while(true) {
                final int c = read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static long nextLong() throws IOException {
            boolean plus = false;
            long ret = 0;
            while(true) {
                final int c = read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static char nextChar() throws IOException {
            while(true) {
                final int c = read();

                if(c == -1) {
                    endInput = true;
                    return '\0';
                }

                if(!isSpace[c]) {
                    return (char)c;
                }
            }
        }

        private static String next() throws IOException {
            buf.setLength(0);

            while(true) {
                final int c = read();

                if(c == -1) {
                    endInput = true;
                    return "-1";
                }

                if(!isSpace[c]) {
                    buf.append((char)c);
                    break;
                }
            }

            while(true) {
                final int c = read();

                if(c == -1 || isSpace[c]) {
                    break;
                }
                buf.append((char)c);
            }

            return buf.toString();
        }

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

    }

}