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.util.*;
import java.io.*;
 
public class DivisibleSequence{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        
        
        int [][] mas=new int [100001][6];
    
        
        
        mas[0][0]=1;
        
        
        for (int i = 1; i < mas.length; i++) {
            int k=ragaca(i);
            for (int j = 0; j < 6; j++) {
                mas[i][j]=mas[i-1][j];
            }
            mas[i][k]++;
        }
        
        int [] m=new int [10];
        
        
        if(n<100000) {
            for (int i = 0; i < 6; i++) {
                m[i]=mas[n][i];
            }           
        }else{
            int t=(n/100000)-1;
            int z=n%100000;
            for (int i = 0; i < m.length; i++) {
                for (int j = 0; j <=i; j++) {
                    if(i-j<6 && j<6){
                        m[i]+=mas[t][j]*mas[99999][i-j];
                    }
                }
            }   

            int k=ragaca(t+1);
            for (int i = k; i < m.length; i++) {
                if(i-k<6){
                    m[i]+=mas[z][i-k];
                
                }
            }   
        }
        
        
        
        m[0]--;
        
        
        long  ans=0;
        long p=1000000007;
    
        
        
        
        for (int i1 = 0; i1 < 4; i1++) {
            for (int i2 = i1; i2 < 4; i2++) {
                for (int i3 = i2; i3 < 4; i3++) {
                    for (int i4 = i3; i4 < 4; i4++) {
                        for (int i5 = i4; i5 < 5; i5++) {
                            for (int i6 = i5; i6 < 9; i6++) {
                                for (int i7 = i6; i7 < m.length; i7++) {
                                    
                                    
                                    
                                    if(i1+i2+i3+i4+i5+i6<i7){
                                        
                                        int [] raod=new int [10];
                                        raod[i1]++;     raod[i3]++; raod[i6]++;
                                        raod[i2]++;     raod[i4]++; raod[i5]++;
                                        raod[i7]++;
                                        
                                        
                                        
                                        long total=1;
                                        
                                        
                                        for (int i = 0; i < 10; i++) {
                                                for (int j = 0; j < raod[i]; j++) {
                                                    total=((total*(m[i]-j)%p)*pow(j+1,(int) p-2, (int )p)) %p;
                                                }
                                        }
                                        ans=(ans+720*total)%p;
                                        
                                    }
                                    
                                    
                                    
                                    
                                    
                                    
                                }
                            }
                        }
                    }
                }
            }
        }
        
        System.out.println(ans);
        
        
        
        
        
        
        
        
        
        
        
        
    }
    
    static long pow(long a, int r, long p){
        if(r==0) return 1L;
        long  x=pow(a, r/2,p);
        if(r%2==1)
            return x*x*a%p;
        return x*x%p;
    }

    static int ragaca(int n){
        int total=0;
        String s=""+n;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)=='4' || s.charAt(i)=='7') total++;
        }
        return total;
    }
}