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.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.io.InputStreamReader;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AlexFetisov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB_ElephantAndParties solver = new TaskB_ElephantAndParties();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB_ElephantAndParties {
        String m;
        int[][][] dp;
        public static int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            m = in.nextString();
            dp = new int[10][2][10];
            ArrayUtils.fill(dp, -1);
            int[] total = new int[10];
            for (int i = 0; i < 10; ++i) {
                total[i] = rec(0, 1, i);
            }
            total[0]--;
            int res = 0;
//        System.err.println(ArrayUtils.toString(total));
            for (int am = 1; am < 10; ++am) {
                for (int i1 = 0; i1 < am; ++i1) {
                    for (int i2 = 0; i2 < am && i1 + i2 < am; ++i2) {
                        for (int i3 = 0; i3 < am && i1 + i2 + i3 < am; ++i3) {
                            for (int i4 = 0; i4 < am && i1 + i2 + i3 + i4 < am; ++i4) {
                                for (int i5 = 0; i5 < am && i1 + i2 + i3 + i4 + i5 < am; ++i5) {
                                    for (int i6 = 0; i6 < am && i1 + i2 + i3 + i4 + i5 + i6 < am; ++i6) {
                                        int[] a = new int[10];
                                        ++a[i1];
                                        ++a[i2];
                                        ++a[i3];
                                        ++a[i4];
                                        ++a[i5];
                                        ++a[i6];
                                        long cur = 1;
                                        for (int j = 0; j < am; ++j) {
                                            cur *= calcC(total[j], a[j]);
                                            cur %= MOD;
                                            if (cur == 0) break;
                                        }
                                        res += (int) (cur * 1L * total[am] % MOD);
                                        if (res >= MOD) {
                                            res -= MOD;
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
            }
            out.println(res);
        }

        private long calcC(int n, int k) {
            // c[n][6];
            if (k > n) return 0;

            long rr = 1;
            for (int i = n, j = 0; j < k; ++j, --i) {
                rr *= i;
                rr %= MOD;
            }
            return rr;
        }

        private int rec(int len, int eq, int am) {
            if (am < 0) return 0;
            if (len >= m.length()) {
                if (am == 0)
                    return 1;
                return 0;
            }
            if (dp[len][eq][am] != -1) return dp[len][eq][am];
            int res = 0;
            int cd = m.charAt(len) - '0';
            if (eq == 0) {
                cd = 10;
            }
            for (int d = 0; d < cd; ++d) {
                if (d != 4 && d != 7) {
                    res += rec(len + 1, 0, am);
                } else {
                    res += rec(len + 1, 0, am - 1);
                }
                if (res >= MOD) res -= MOD;
            }
            if (cd < 10) {
                int nam = am;
                if (cd == 4 || cd == 7) --nam;
                res += rec(len + 1, 1, nam);
                if (res >= MOD) res -= MOD;
            }
            dp[len][eq][am] = res;
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String nextString() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

    }

    static class ArrayUtils {
        public static void fill(int[][] f, int value) {
            for (int i = 0; i < f.length; ++i) {
                Arrays.fill(f[i], value);
            }
        }

        public static void fill(int[][][] a, int value) {
            for (int i = 0; i < a.length; ++i) {
                fill(a[i], value);
            }
        }

    }
}