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

public class D implements Runnable {

    
    static class State {
        int cur_lucky;
        ArrayList<Integer> path;
        
        public State(int cur_lucky, ArrayList<Integer> path) {
            super();
            this.cur_lucky = cur_lucky;
            this.path = path;
        }

        public String toString() {
            return "State [cur_lucky=" + cur_lucky + ", path=" + path + "]";
        }
        
        
        
    }
    
    final static int MOD = 1000000007;
    int m, len, luckys;
    int[][][][] dp;
    
    String a, b;
    
    private int go(int i, boolean normal1, boolean normal2, int luckys) {
        if (i == len) {
            if (luckys == this.luckys)
                return 1;
            return 0;
        } else {
            if (dp[i][normal1 ? 1 : 0][normal2 ? 1 : 0][luckys] != -1) return dp[i][normal1 ? 1 : 0][normal2 ? 1 : 0][luckys];
            int res = 0;
            for (char c = '0'; c <= '9'; c++) {
                if (c >= a.charAt(i) || normal1) {
                    if (c <= b.charAt(i) || normal2) {
                        res += go(i + 1, normal1 || (c > a.charAt(i)), normal2 || (c < b.charAt(i)), luckys + ((c == '4' || c == '7') ? 1 : 0));
                    }
                }
            }
            return dp[i][normal1 ? 1 : 0][normal2 ? 1 : 0][luckys] = res;
        }
    }
    
    private void solve() throws IOException {
        m = nextInt();
        len = ("" + m).length();
        
        a = "1";
        b = "" + m;
        
        while (a.length() < b.length())
            a = "0" + a;
        
        dp = new int[11][2][2][11];
        
        int[] many = new int[11];
        int[] original = new int[11];
        
        for (int i = 0; i < 11; i++) {
            for (int[][][] d : dp) for (int[][] dd : d) for (int[] ddd : dd) Arrays.fill(ddd, -1);
            luckys = i;
            many[i] = go(0, false, false, 0);
            original[i] = many[i];
        }
        
        long res = 0;
        long mul = 1;
        for (int i = 1; i < 11; i++) {
            Queue<State> Q = new LinkedList<D.State>();
            Q.add(new State(i, new ArrayList<Integer>()));
            while (!Q.isEmpty()) {
                State cur = Q.poll();
                
                if (cur.path.size() == 6) {
                    for (int e : cur.path) {
                        mul = (mul * many[e]) % MOD;
                        if (many[e] > 0)
                            many[e]--;
                    }
                    res = (res + (mul * many[i]) % MOD) % MOD;
                    System.arraycopy(original, 0, many, 0, 11);
                    mul = 1;
                    continue;
                }
                
                for (int j = 0; j < i; j++) {
                    if (cur.cur_lucky - j <= 0) continue;
                    ArrayList<Integer> now = new ArrayList<Integer>();
                    for (int c : cur.path) now.add(c);
                    now.add(j);
                    Q.add(new State(cur.cur_lucky - j, now));
                }
            }
        }
        pl(res);
    }   

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

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

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}