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

public class a{ 
     static int[] count,count1;
     static int[] arr;
     static char[] ch,ch1;
     static long[] darr;
     static Character[][] mat,mat1;
     static int x,h;
     static long maxl;
     static double dec;
     static String s;
     static long minl;
     static int mx = (int)1e6;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a,g;
     static long b;
     static long c;
     static long d;
     static int y,z;
     static int m;
     static long k;
     static int q;
     static String[] str,str1;
     static Set<Long> set,set1;
     static List<Integer> list,list1;
     static Map<String,Integer> map;
     static StringBuilder sb,sb1,sb2;

     public static void solve(){

        long prod = 1;
        long prod9 = 1;
        long maxl = 0;
        int n = ch.length;

        for(int i = 0 ; i< n ; i++)
            prod9 *= 9;

        for(int i = 0 ; i < n ;i++){

            prod9 /= 9;

            if(ch[i] == '0'){
                break;
            }
            
            if(ch[i] == '1'){
                if( i == 0)
                    maxl = Math.max(maxl,prod9*prod*(1));
            }
            else{
                maxl = Math.max(maxl,prod9*prod*(ch[i]-'1'));
            }
            prod *= (ch[i]-'0');

        }

        System.out.println(Math.max(maxl,prod));

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            while(t > 0){
                
                // x = sc.nextLong();
                // y = sc.nextLong();
                // z = sc.nextLong();
                
                // a = sc.nextLong();
                // b = sc.nextLong();
                // c = sc.nextLong();
                // d = sc.nextLong();
                // n = sc.nextLong();
                // n = sc.nextInt();
                // y = sc.nextInt();
                // x = sc.nextInt();

                // y = sc.nextLong();
                // n1 = sc.nextInt();
                // n = sc.nextLong();

                // k = sc.nextLong();

                ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                // m = sc.nextInt();
                // k = sc.nextLong();

                // arr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     arr[i] = sc.nextInt();
                // }
                
                 
                // darr = new long[m];
                // for(int i = 0; i < m ; i++){
                //     darr[i] = sc.nextLong();
                // }
                
                // n1 = sc.nextInt();
                //  darr = new long[n1];
                //  for(int i = 0; i < n1 ; i++){
                //      darr[i] = sc.nextLong();
                //  }

                // mat = new Character[n][n];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < n ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }
                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // System.out.println(solve()?"YES":"NO");
                 solve();       
                 // System.out.println(solve());

                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // } 

    static final Random random=new Random();
    
    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        int first;
        int second;
        Node(int f,int s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}