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

public class TaskB implements Runnable {
    
    private long sum[][];
    
    private long eval(int n, int maxi, int now, String s, boolean bound) {
        
        if (maxi < now) {
            return 0;
        }
        
        if (n == 0) {
            if (maxi == now && bound) {
                return 1;
            }
            
            return 0;
        }
        
        long ret = 0;
        int up = s.charAt(s.length() - n) - '0';
        for (int next = 0; next <= up; ++next) {
            if (next < up) {
                int nextnow = now;
                if (next == 4 || next == 7) {
                    ++nextnow;
                }
                
                if (nextnow <= maxi) {
                    int need = maxi - nextnow;
                    ret += sum[n - 1][need];
                }
            } else {
                int nextnow = now;
                if (next == 4 || next == 7) {
                    ++nextnow;
                }
                
                ret += eval(n - 1, maxi, nextnow, s, bound);
            }
        }
        
        return ret;
    }
    
    final int MOD = 1000000007;
    
    private int powMod(int x, int y) {
        int ret = 1;
        for (; y > 0; y >>= 1) {
            if (y % 2 != 0) {
                ret = (int)((long)ret * x % MOD);
            }
            
            x = (int)((long)x * x % MOD);
        }
        
        return ret;
    }
    
    private long choose(int x, int y) {
        long ret = 1;
        for (int i = x - y + 1; i <= x; ++i) {
            ret = ret * i % MOD;
        }
        
        for (int i = 1; i <= y; ++i) {
            ret = ret * powMod(i, MOD - 2) % MOD;
        }
        
        return ret;
    }

    private void solve() throws IOException {
        
        int m = nextInt();
        sum = new long[13][13];
        sum[0][0] = 1;
        for (int i = 0; i < 12; ++i) {
            for (int j = 0; j < 12; ++j) {
                if (sum[i][j] != 0) {
                    for (int next = 0; next < 10; ++next) {
                        int nextj = j;
                        if (next == 4 || next == 7) {
                            ++nextj;
                        }
                        
                        sum[i + 1][nextj] += sum[i][j];
                    }
                }
            }
        }

        String str = Integer.valueOf(m).toString();
        while (str.length() < 10) {
            str = "0" + str;
        }
        
        System.err.println(str);
        
        long ones[] = new long[10];
        for (int have = 0; have <= 9; ++have) {
            ones[have] = eval(10, have, 0, str, true);
            
            System.err.println("have = " + have + " val = " + ones[have]);
        }
        
        --ones[0];
        long ret = 0;
        for (int me = 1; me <= 9; ++me) {
            if (ones[me] >= 1) {
                
                long dp[][][] = new long[10][7][me + 1];
                dp[0][0][0] = 1;
                for (int i = 0; i < me; ++i) {
                    for (int j = 0; j <= 6; ++j) {
                        for (int k = 0; k < me; ++k) {
                            for (int pick = 0; pick <= ones[i] && j + pick <= 6 && k + i * pick < me; ++pick) {
                                dp[i + 1][j + pick][k + i * pick] += dp[i][j][k] * choose((int)ones[i], pick);
                                dp[i + 1][j + pick][k + i * pick] %= MOD;
                            }
                        }
                    }
                }
                
                long total = 0;
                for (int i = 0; i < me; ++i) {
                    total += dp[me][6][i];
                }
                
                total %= MOD;
                
                total = total * ones[me] % MOD;
                
                for (int i = 1; i <= 6; ++i) {
                    total = total * i % MOD;
                }
                
                ret = (ret + total) % MOD;
                
            }
        }
        
        writer.println(ret);
    }

    public static void main(String[] args) {
        new TaskB().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}