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 Main {
    int c[][], two[], eight[];
    int Mod = 1000000007;

    int num[], dep = 0, ans = 0;
    int have[];

    void dfs(int idx, int get) {
        if (idx == 0)
            return;
        int cnt, st = 0;
        if (idx == dep)
            st = 1;
        for (int i = st; i < num[idx]; ++i) {
            for (int j = 0; j < idx; ++j) {
                cnt = j;
                if (i == 7 || i == 4)
                    ++cnt;
                have[cnt + get] = (have[cnt + get] + c[idx - 1][j]) % Mod;
            }
        }

        if (idx > 1) {
            for (int i = 1; i <= 9; ++i) {
                for (int j = 0; j < idx - 1; ++j) {
                    cnt = j;
                    if (i == 4 || i == 7)
                        ++cnt;
                    have[cnt] = (have[cnt] + c[idx - 2][j]) % Mod;
                }
            }
        }

        if (num[idx] == 4 || num[idx] == 7)
            dfs(idx - 1, get + 1);
        else
            dfs(idx - 1, get);
    }

    void find(int idx, int mx, int tot) {
        if (idx == 7) {
            int get = 1;
            for (int i = 0; i <= 6; ++i)
                get = (int) ((long) get * num[i] % Mod);
            ans = (ans + get) % Mod;
        } else {
            for (int i = 0; i + tot < mx; ++i)
                if (have[i] > 0) {
                    num[idx] = have[i];
                    --have[i];
                    find(idx + 1, mx, tot + i);
                    ++have[i];
                }
        }
    }

    void run() throws IOException {
        int sz = 12;
        c = new int[sz][sz];
        for (int i = 0; i < sz; ++i) {
            c[i][i] = c[i][0] = 1;
            for (int j = 1; j < i; ++j)
                c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % Mod;
        }
        two = new int[sz];
        two[0] = 1;
        for (int i = 1; i < sz; ++i)
            two[i] = two[i - 1] * 2 % Mod;
        for (int i = 0; i < sz; ++i)
            for (int j = 0; j <= i; ++j)
                c[i][j] = (int) (((long) c[i][j] * two[j]) % Mod);

        eight = new int[sz];
        eight[0] = 1;
        for (int i = 1; i < sz; ++i)
            eight[i] = (int) ((long) eight[i - 1] * 8 % Mod);
        for (int i = 0; i < sz; ++i)
            for (int j = 0; j <= i; ++j)
                c[i][j] = (int) ((long) c[i][j] * eight[i - j] % Mod);
        have = new int[sz];
        num = new int[sz];

        int m = cin.nextInt(), cnt = 0;
        while (m > 0) {
            num[++dep] = m % 10;
            if (num[dep] == 4 || num[dep] == 7)
                ++cnt;
            m /= 10;
        }
        ++have[cnt];
        dfs(dep, 0);
        // for (int i = 0; i < sz; ++i)
        // out.println(i + " " + have[i]);

        for (int i = 1; i < sz; ++i)
            if (have[i] > 0) {
                num[0] = have[i];
                --have[i];
                find(1, i, 0);
                ++have[i];
            }
        out.println(ans);
        out.close();
    }

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

    Main() {
        cin = new InputReader(System.in);
        // cin = new Scanner(System.in);
        out = new PrintWriter(System.out);
    }

    PrintWriter out;
    InputReader cin;

    // Scanner cin;

    class InputReader {
        InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            // try {
            // reader = new BufferedReader(new FileReader("E.in"));
            // } catch (FileNotFoundException ex) {
            // }
            tokenizer = new StringTokenizer("");
        }

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

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

        private BufferedReader reader;
        private StringTokenizer tokenizer;
    }
}