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.*;
import java.util.*;

public class Main
{
   public static void main(String[] args) throws IOException
   {
      new Main().run();
   }

   StreamTokenizer in;
   PrintWriter out;

   int nextInt() throws IOException
   {
      in.nextToken();
      return (int)in.nval;
   }
   long nextLong() throws IOException
   {
      in.nextToken();
      return (long)in.nval;
   }
   public static long fact(long n){
long i=n,j,result;
result = 1;
for (j=i;j>=1;j--)
result = result*j;
return result;
}

public static long ncr(long n,long r){
long i=n,j,result;
result = 1;
for (j=n;j>=n-r+1;j--)
result = result*j;
return result/fact(r);
}

public static double npr(long n,long r){
double i=n,j,result;
result = 1;
for (j=n;j>=n-r+1;j--)
result = result*j;
return result;
}
   void run() throws IOException
   {
     // in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
     // out = new PrintWriter(new FileWriter("output.txt"));
      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    out = new PrintWriter(new OutputStreamWriter(System.out));
      solve();
      out.flush();
   }

   void solve() throws IOException
   {  long[][] A= new long[10][10];
   int[] Am= new int[10];
   long M=nextLong();
   long[] dg=new long[11];
   int z=9;
   while(M>0&&z>=0){
   dg[z]=M%10;
   M/=10;
   z--;
   }
   if(dg[0]==1)M=999999999;
   z=9;
   while(M>0&&z>=0){
   dg[z]=M%10;
   M/=10;
   z--;
   }
//       for (int i = 1; i < 10; i++) {
//           System.out.println(i+ " "+dg[i]);
//       }
   A[0][0]=0;
   Am[0]=0;
   long L=1000000007;
       for (int d = 1; d < 10; d++) {
           for (int l = 0; l <=d ; l++) {
               if(l>=1)
               {A[d][l]+=(A[d-1][l-1]*2);A[d][l]%=L;}
               
               A[d][l]+=(A[d-1][l]*8);
               A[d][l]%=L;
               
            
           }
           if(dg[d]==7||dg[d]==4)
               Am[d]=Am[d-1]+1;
           else
               Am[d]=Am[d-1];
            if(dg[d]>7){  
               {A[d][Am[d-1]+1]+=2;}
               A[d][Am[d-1]]+=dg[d]-2;}
            else  if(dg[d]==7){  
               {A[d][Am[d-1]+1]+=1;}
               A[d][Am[d-1]]+=dg[d]-1;}
            else  if(dg[d]>4){  
               {A[d][Am[d-1]+1]+=1;}
               A[d][Am[d-1]]+=dg[d]-1;}
            else  if(dg[d]==4){  
               {A[d][Am[d-1]+1]+=0;}
               A[d][Am[d-1]]+=dg[d];}
            else  if(dg[d]<4){  
               {A[d][Am[d-1]+1]+=0;}
               A[d][Am[d-1]]+=dg[d];}
                 
                      
                       
       }
       
       A[9][Am[9]]++;
       A[9][0]+=(long)dg[0];
       A[9][0]--; // fro 0
long[] sum=new long[10];
       for (int i = 1; i < 10; i++) {
          
           sum[i]=sum[i-1]+A[9][i-1];
           sum[i]%=L;
         //  System.out.println("  sdfs "+sum[i]);
       }
long ans=0;
   //    System.out.println("skjfnws "+A[9][2]);
       for (int i = 1; i < 10; i++) {
         //  System.out.println("mccccccccccccc "+i);
           long par=A[9][i];
     long par2=0;
           for (int j8 = 0; j8 < 2; j8++) {
               for (int j7 = 0; j7 < 2; j7++) {
                   for (int j6 = 0; j6 < 2; j6++) {
                       for (int j5 = 0; j5 < 2; j5++) {
                           for (int j4 = 0; j4 < 3; j4++) {
                               for (int j3 = 0; j3 < 3; j3++) {
                                   for (int j2 = 0; j2 < 5; j2++) {
                                       for (int j1 = 0; j1 < 7; j1++) {
                                           for (int j0 = 0; j0 < 7; j0++) {
                                               if((j0+j1+j2+j3+j4+j5+j6+j7+j8==6)&&(j1+j2*2+j3*3+j4*4+j5*5+j6*6+j7*7+j8*8<i)){
                                                   long par3=1;
                                                   for (int j = 0; j < j0; j++) {
                                                       par3*=(A[9][0]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j1; j++) {
                                                       par3*=(A[9][1]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j2; j++) {
                                                       par3*=(A[9][2]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j3; j++) {
                                                       par3*=(A[9][3]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j4; j++) {
                                                       par3*=(A[9][4]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j5; j++) {
                                                       par3*=(A[9][5]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j6; j++) {
                                                       par3*=(A[9][6]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j7; j++) {
                                                       par3*=(A[9][7]-j);
                                                       par3%=L;
                                                   }
                                                   for (int j = 0; j < j8; j++) {
                                                       par3*=(A[9][8]-j);
                                                       par3%=L;
                                                   }
                                                 //  System.out.println(j0+" "+j1+" "+j2+" "+j3+" "+j4+" "+j5+" "+j6+" "+j7+" "+j8);
                                               par3*=ncr(6, j0);
                                               par3%=L;
                                                par3*=ncr(6-j0, j1);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1, j2);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2, j3);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2-j3, j4);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2-j3-j4, j5);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2-j3-j4-j5, j6);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2-j3-j4-j5-j6, j7);
                                               par3%=L;
                                                par3*=ncr(6-j0-j1-j2-j3-j4-j5-j6-j7, j8);
                                               par3%=L;
                                               
                                               par2+=par3;
                                               par2%=L;
                                               }
                                           }
                                       }
                                   }
                               }
                           }
                       }
                   }
               }
           }
                
     
     
     
     
     
     
     
     
     
     
     par=par*par2;
     par%=L;
              ans+=par;
         ans%=L;
        //   out.println(par+"  psr");//284823327
       }
       out.println(ans);
//       for (int i = 0; i < 10; i++) {
//           System.out.println("");
//           for (int j = 0; j < 10; j++) {
//              // System.out.print(" "+A[i][j]);
//           }
//       }
           
   
   
   }
   
}