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.io.BufferedWriter;
import java.io.UnsupportedEncodingException;
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 sokokaleb (sokokaleb@gmail.com)
 */
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 {
    long dp[][][] = new long[13][13][13],dp2[][][] = new long[13][13][2];
    public final long MOD = 1000000007L;
    String S;
    int sz;
    OutputWriter zz;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        // dp = jumlah luki, sisa orang, jumlah lucky | dp2 = panjang, sisa lucky, underflow apa kagak
        sz = in.readInt();
        zz=out;
        S = Integer.toString(sz);
        sz = S.length();
        long ans = 0L;
        for (int i=0;i<=12;++i)
            for (int j=0;j<=12;++j)
                Arrays.fill(dp[i][j],-1);
        for (int i=0;i<=sz;++i)
            for (int j=0;j<=sz;++j)
                Arrays.fill(dp2[i][j],-1);
//        if (true)
//        {
//            out.printLine(f2(0));
//            return ;
//        }
        for (int sum=0;sum<sz;++sum)
            for (int party=sum+1;party<=sz;++party)
            {
                ans=(ans+f2(party)*f(0,6,sum))%MOD;
//                out.printLine(f2(party),"|",f(0,6,sum));
            }
        out.printLine(ans);
    }

    public long f(int tot,int n,int lleft)
    {
        long ret=dp[tot][n][lleft];
        if (ret!=-1) return ret;
        ret=0;
        if (tot==12) return dp[tot][n][lleft]=(lleft==0 && n==0)?1:0;
        for (int i=0;i<=n && i*tot<=lleft;++i)
        {
            long tmp = f(tot+1,n-i,lleft-i*tot);
            tmp = (tmp*C(n,i))%MOD;
            tmp = (tmp*P(f2(tot),i))%MOD;
//            zz.printLine(tot,n,lleft,f2(tot),i);
            ret=(ret+tmp)%MOD;
        }
        return dp[tot][n][lleft]=ret;
    }

    public long f2(int lleft)
    {
        if (lleft==0) return f2(0,lleft,0)-1;
        else return f2(0,lleft,0);
    }
    public long f2(int pos,int lleft,int under)
    {
        if (pos==sz) return (lleft==0)?1:0; // uwis entek
        long ret=dp2[pos][lleft][under];
        if (ret!=-1) return ret;
        ret=0;
        for (int next = 9;next>=0;--next)
        {
            int lucky = (next==4 || next==7)?1:0;
            int nun = under;
            if (next>S.charAt(pos)-'0' && under==0)
                continue;
            if (next<S.charAt(pos)-'0')
                nun=1;
            if (lleft>=lucky)
                ret=(ret+f2(pos+1,lleft-lucky,nun));
        }
        return dp2[pos][lleft][under]=ret;
    }

    public long C(long a,long b)
    {
        long ret=1;
        for (long i=0;i<b;++i) ret*=(a-i);
        for (long i=1;i<=b;++i) ret/=i;
        return ret;
    }

    public long P(long a,long b)
    {
        long ret=1;
        for (long i=0;i<b;++i) ret=(ret*(a-i))%MOD;
        return ret;
    }
}

class OutputWriter {
    private final PrintWriter out;

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

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

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                out.print(' ');
            out.print(objects[i]);
        }
    }

    public void printLine(Object...objects)
    {
        print(objects);
        out.write('\n');
    }

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

    }

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    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 readInt() {
        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 - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

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

    }