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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskD {
    private final int mod = 1000000007;
    int m;
    int[][][] dp;
    int[] count;
    int[] digits;
    int maxSum;
    int current;
    int[] have;
    long mult;
    long answer;

    int get(int less, int from, int need) {
        if (need < 0) return 0;
        if (from == digits.length) return need == 0 ? 1 : 0;
        if (dp[less][from][need] != -1) return dp[less][from][need];
        int ret = 0;
        int maxDig = less == 1 ? 9 : digits[from];
        for (int i = 0; i <= maxDig; i++) {
            int nxtNeed = need;
            if (i == 4 || i == 7) nxtNeed--;
            int nxtLess = less;
            if (nxtLess == 0 && i != maxDig)
                nxtLess = 1;
            ret += get(nxtLess, from + 1, nxtNeed);
            if (ret >= mod)
                ret -= mod;
        }
        return dp[less][from][need] = ret;
    }

    void precalc() {
        dp = new int[2][11][11];
        for (int i = 0; i < dp.length; i++)
            for (int j = 0; j < dp[0].length; j++)
                for (int k = 0; k < dp[0][0].length; k++)
                    dp[i][j][k] = -1;
        String sm = "" + m;
        digits = new int[sm.length()];
        for (int i = 0; i < digits.length; i++)
            digits[i] = sm.charAt(i) - '0';
        count = new int[10];
        for (int i = 0; i < 10; i++)
            count[i] = get(0, 0, i);
        count[0]--;
    }

    void dfs(int k, int sum) {
        if (sum >= maxSum) return;
        if (k == 6) {
            long now = 1;
            for (int i = 0; i < 10; i++) {
                int ppl = 0;
                for (int j = 0; j < 6; j++)
                    if (have[j] == i)
                        ppl++;
                if (ppl == 0) continue;
                for (int j = 0; j < ppl; j++)
                    now = (now * (count[i] - j)) % mod;
            }
            mult = (mult + now) % mod;
        } else {
            for (int i = 0; i < 10; i++) {
                have[k] = i;
                dfs(k + 1, sum + i);
            }
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        m = in.nextInt();
        precalc();
        have = new int[7];
        answer = 0;
        for (maxSum = 1; maxSum <= 9; maxSum++) {
            current = count[maxSum];
            mult = 0;
            dfs(0, 0);
            answer += (current * mult) % mod;
            if (answer >= mod)
                answer -= mod;
        }
        out.println(answer);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
}