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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.util.BitSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

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

class TaskB {
    int MOD = (int) (1e9+7);
    long[][] C = MathUtils.generateCombination(11, MOD);
    long[] pow2 = MathUtils.generatePowers(2, 11, MOD);
    long[] pow8 = MathUtils.generatePowers(8,11,MOD);
    public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
        int m = in.nextInt() + 1;
        int[] ms = new int[10];
        for(int i=0;i<10;i++){
            ms[i] = m%10; m/=10;
        }
        int[] cnt = count(ms, 9);
        cnt[0]--;
        long res = 0;
        for(int c=9;c>=0;c--){
            res += calc(cnt,c-1,6,c) * cnt[c];
        }
        res %= MOD;
        out.println(res);
    }

    private long calc(int[] cnt, int index, int rest, int capacity) {
        if(index<0){
            return rest==0 && capacity>0 ? 1 : 0;
        }else{
            long res = 0;
            long way = 1;
            for(int use=0;use<rest+1;use++){
                res += calc(cnt,index-1,rest-use,capacity- index * use) * way % MOD * C[rest][use] % MOD;
                if(res >= MOD)res -= MOD;
                way *= cnt[index] - use + MOD;
                way %= MOD;
            }
            return res;
        }
    }

    private int[] count(int[] m, int d) {// [m9..md+1 0..0, m9..md+1 md .. m0)
        if(d<0)return new int[10];
        int[] res = count(m, d-1);
        // [m9..md+1 0..0, m9..md+1 md 0..0)
        int c1 = 0;
        for(int i=9;i>d;i--)c1 += cnt47(m[i]);
        for(int md=0;md<m[d];md++){
            // md-1..m0
            int c2 = cnt47(md);
            for(int c3=0;c3<=d;c3++){
                long way = C[d][c3] * pow2[c3] % MOD * pow8[d-c3] % MOD;
                res[c1 + c2 + c3] += way;
                if(res[c1 + c2 + c3] >= MOD)res[c1 + c2 + c3] -= MOD;
            }
        }
        return res;
    }

    private int cnt47(int i) {
        return i==4 || i==7 ? 1 : 0;
    }
}

class MathUtils {

    public static long[][] generateCombination(int n, int modulus) {
        long[][] C = new long[n][n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < i + 1; j++) {
                C[i][j] = j == 0 ? 1 : C[i - 1][j - 1] + C[i - 1][j];
                if (C[i][j] >= modulus) C[i][j] -= modulus;
            }
        return C;
    }

    public static long[] generatePowers(int base, int count, int modulus) {
        long[] res = new long[count];
        for (int i = 0; i < count; i++){
            res[i] = (i==0 ? 1 : res[i-1] * base) % modulus;
        }
        return res;
    }
}

class MyScanner {
    private final InputStream in;

    public MyScanner(InputStream in) {
        this.in = in;
    }

    int bufLen;
    int bufPtr;
    byte[] buf = new byte[1024];

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

    public int nextInt() {
        try {
            int c = read();
            if (c == -1) return c;
            while (c != '-' && (c < '0' || '9' < c)) {
                c = read();
                if (c == -1) return c;
            }
            if (c == '-') return -nextInt();
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ('0' <= c && c <= '9');
            return res;
        } catch (Exception e) {
            return -1;
        }
    }


    }

class MyPrintWriter {
    PrintWriter out;

    public MyPrintWriter(OutputStream outputStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public MyPrintWriter(Writer writer) {
        out = new PrintWriter(writer);
    }

    public void println(Object... os) {
        for (int i = 0; i < os.length - 1; i++) {
            out.print(os[i]);
            out.print(' ');
        }
        out.println(os[os.length - 1]);
    }

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

    }