Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.

Help Kurt find the maximum possible product of digits among all integers from 1 to n.

Input

The only input line contains the integer n (1 ≤ n ≤ 2⋅10^9).

Output

Print the maximum product of digits among all integers from 1 to n.

Examples

Input


390


Output


216


Input


7


Output


7


Input


1000000000


Output


387420489

Note

In the first example the maximum product is achieved for 389 (the product of digits is 3⋅8⋅9=216).

In the second example the maximum product is achieved for 7 (the product of digits is 7).

In the third example the maximum product is achieved for 999999999 (the product of digits is 9^9=387420489).
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.io.*;
public class codeforces 
{ 
   static class Student{
        int a,s,gd,gs;
        Student(int a,int b,int c,int d){
            this.a=a;
            this.s=b;
            gd=c;
            gs=d;
        }
    }
static    class Sortbyroll implements Comparator<Student> 
{ 
    // Used for sorting in ascending order of 
    // roll number 
    public int compare(Student c, Student b) 
    { 
        if(c.s>b.s)
            return -1;
        else if(c.s==b.s){
            if(c.gd>b.gd)
                return -1;
            else if(c.gd==b.gd){
                if(c.gs>b.gs)
                    return -1;
                else if(c.gs==b.gs){
                    if(c.a>b.a)
                        return -1;
                    else
                        return 1;
                }
            }
            else
                return 1;
        }
        return 1;
    } 
} 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    public static void main(String[] args){
        //long sum=0;
        int t,n,d,c,i,q=0,x,pos,c_0=-1,c_1=-1,si=0;
        long max=1;
        FastReader sc=new FastReader();
        String s;
        //t=sc.nextInt();
         //n=sc.nextInt();
        s=sc.nextLine();
        long dp[]=new long[s.length()];
        dp[s.length()-1]=s.charAt(s.length()-1)-'0';
        for(i=s.length()-2;i>=0;i--){
            x=s.charAt(i)-'0';
            if(x>=1)
            dp[i]=Math.max((long)(x-1)*(long)Math.pow(9,s.length()-1-i),(long)x*dp[i+1]);
        }
        dp[0]=Math.max(dp[0],(long)Math.pow(9,s.length()-1));
        System.out.println(dp[0]);
    }
}