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.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.math.BigDecimal;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskB {
    public static final long MOD = (long) (1e9 + 7);
    private static long[][] C = NumberUtils.generateBinomialCoefficients(20, MOD);
    private long[] record = new long[10];
    private int maxLen;
    private long answer;

    private void calc(int n, long fac, int has) {
        for (int k = 0; k <= n; k++) {
            if (k + has >= 10)
                break;
            record[k + has] += C[n][k] * NumberUtils.powMod(2, k, MOD) % MOD * NumberUtils.powMod(8, n - k, MOD) % MOD * fac % MOD;
            if (record[k + has] >= MOD)
                record[k + has] -= MOD;
        }
    }

    private void calc(String num, int has) {
        int firstDigit = num.charAt(0) - '0';
        if (num.length() == 1) {
            int count = firstDigit + 1;
            if (firstDigit >= 4) {
                record[has + 1]++;
                count--;
            }
            if (firstDigit >= 7) {
                record[has + 1]++;
                count--;
            }
            record[has] += count;
            if (record[has] >= MOD)
                record[has] -= MOD;
            if (record[has + 1] >= MOD)
                record[has + 1] -= MOD;
            return;
        }
        if (firstDigit == 7) {
            calc(num.substring(1), has + 1);       //7
            calc(num.length() - 1, 1, has + 1);    //4
            calc(num.length() - 1, 6, has);        //0,1,2,3,5,6
        } else if (firstDigit == 4) {
            calc(num.substring(1), has + 1);       //4
            calc(num.length() - 1, 4, has);        //0,1,2,3
        } else {
            int count = firstDigit + 1;
            if (firstDigit >= 4) {
                count--;
                calc(num.length() - 1, 1, has + 1);
            }
            if (firstDigit >= 7) {
                count--;
                calc(num.length() - 1, 1, has + 1);
            }
            calc(num.substring(1), has);
            calc(num.length() - 1, count - 1, has);
        }
    }

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int m = in.nextInt();
        calc(String.valueOf(m), 0);
        record[0]--;
        answer = 0;
        maxLen = String.valueOf(m).length();
        for (int lucky = 0; lucky <= 9; lucky++) {
            deal(lucky, new int[6], 0, 0);
        }
        out.println(answer);
    }

    private void deal(int lucky, int[] l, int index, int currentSum) {
        if (index >= 6) {
            work(lucky, l);
            return;
        }
        for (int i = 0; i <= maxLen; i++) {
            if (currentSum + i >= lucky) {
                break;
            }
            l[index] = i;
            deal(lucky, l, index + 1, currentSum + i);
        }
    }

    private void work(int lucky, int[] l) {
        long[] rec = record.clone();
        long result = rec[lucky]--;
        for (int item : l) {
            result = result * (rec[item]--) % MOD;
        }
        answer += result;
        if (answer >= MOD)
            answer -= MOD;
    }
}

class NumberUtils {

    public static long powMod(long a, long b, long mod) {
        if (b == 0) {
            return 1L;
        }
        long result = powMod(a, b >> 1, mod);
        result = (result * result) % mod;
        if (b % 2 == 1) {
            result = (result * a) % mod;
        }
        return result;
    }

    public static long[][] generateBinomialCoefficients(int n, long module) {
        long[][] result = new long[n + 1][n + 1];
        if (module == 1)
            return result;
        for (int i = 0; i <= n; i++) {
            result[i][0] = 1;
            for (int j = 1; j <= i; j++) {
                result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
                if (result[i][j] >= module)
                    result[i][j] -= module;
            }
        }
        return result;
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(long x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }