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.*;  

public class Solution{
    public static class pair{
        int x;
        int y;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // int n=Integer.parseInt(br.readLine());
        String line=br.readLine();
        if(line.length()==1){
            System.out.println(line);
            return;
        }
        ArrayList<Long> list=new ArrayList<>();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<line.length();i++){
            char ch=line.charAt(i);
            if(ch=='0'||i==line.length()-1){
                sb.append(ch+"");
            }else{
                char c=(char)(ch-1);
                StringBuffer s=new StringBuffer();
                if(i==0&&c==0){
                    for(int j=0;j<line.length()-i-1;j++){
                        s.append("9");   
                    }
                    list.add(Long.parseLong(s.toString()));
                }else{
                    s.append(line.substring(0,i));
                    s.append(c+"");
                    for(int j=0;j<line.length()-i-1;j++){
                        s.append("9");   
                    }
                    list.add(Long.parseLong(s.toString()));
                }
                sb.append(ch+"");
            }
        }
        list.add(Long.parseLong(sb.toString()));
        long max=Long.MIN_VALUE;
        for(int i=0;i<list.size();i++){
            max=Math.max(z(list.get(i)),max);
        }
        System.out.println(max);
    }
    public static long z(long val){
        long p=1;
        while(val!=0){
            long rem=val%10;
            p*=rem;
            val=val/10;
        }
        return p;
    }
    static boolean isSmaller(String str1, String str2) 
{ 
    // Calculate lengths of both string 
    int n1 = str1.length(), n2 = str2.length(); 
//   System.out.println(n1+" "+n2);
    if (n1 < n2) 
        return true; 
    if (n2 < n1) 
        return false; 
  
    for (int i = 0; i < n1; i++) 
    { 
        if (str1.charAt(i) < str2.charAt(i)) 
            return true; 
        else if (str1.charAt(i) > str2.charAt(i)) 
            return false; 
    } 
    return false; 
} 
  
// Function for finding difference of larger numbers 
static String findDiff(String str1, String str2) 
{ 
    // Before proceeding further, make sure str1 
    // is not smaller 
    if (isSmaller(str1, str2)) 
    { 
        String t = str1;  
        str1 = str2; 
        str2 = t; 
    } 
  
    // Take an empty string for storing result 
    String str = ""; 
  
    // Calculate lengths of both string 
    int n1 = str1.length(), n2 = str2.length(); 
    int diff = n1 - n2; 
  
    // Initially take carry zero 
    int carry = 0; 
  
    // Traverse from end of both strings 
    for (int i = n2 - 1; i >= 0; i--) 
    { 
        // Do school mathematics, compute difference of 
        // current digits and carry 
        int sub = (((int)str1.charAt(i + diff) - (int)'0') - 
                    ((int)str2.charAt(i) - (int)'0') - carry); 
        if (sub < 0) 
        { 
            sub = sub+10; 
            carry = 1; 
        } 
        else
            carry = 0; 
  
        str += String.valueOf(sub); 
    } 
  
    // subtract remaining digits of str1[] 
    for (int i = n1 - n2 - 1; i >= 0; i--) 
    { 
        if (str1.charAt(i) == '0' && carry > 0) 
        { 
            str += "9"; 
            continue; 
        } 
        int sub = (((int)str1.charAt(i) - (int)'0') - carry); 
        if (i > 0 || sub > 0) // remove preceding 0's 
            str += String.valueOf(sub); 
        carry = 0; 
  
    } 
  
    // reverse resultant string  
    return new StringBuilder(str).reverse().toString(); 
} 
    public static int[] soe(int n){
        int[] arr=new int[n];
        arr[0]=0;
        for(int i=1;i<n;i++){
            if(arr[i]==0){
                for(int j=(2*(i+1))-1;j<n;j=j+i+1){
                    arr[j]=1;
                }
            }
        }
        return arr;
    }
    public static int[][] floydWarshall(int graph[][],int V){ 
        int dist[][] = new int[V][V]; 
        int i, j, k; 
        for (i = 0; i < V; i++){ 
            for (j = 0; j < V; j++){
                dist[i][j] = graph[i][j]; 
            }
        }
        for (k = 0; k < V; k++) { 
            for (i = 0; i < V; i++){ 
                for (j = 0; j < V; j++){ 
                    if (dist[i][k] + dist[k][j] < dist[i][j]){ 
                        dist[i][j] = dist[i][k] + dist[k][j]; 
                    }
                } 
            } 
        }
        return dist;
    } 
    public static class Comp implements Comparator<pair>{
        public int compare(pair a,pair b){
            return a.x-b.x;
        }
    }
    public static int gcd(int a,int b){
        if (b == 0) 
        return a; 
        return gcd(b, a % b);
    }
    public static int lcm(int a,int b){
        int x=Math.max(a,b);
        int y=Math.min(a,b);
        long ans=x;
        while(ans%y!=0){
            ans+=x;
        }
        if(ans>Integer.MAX_VALUE){
            return -1;
        }
        return (int)ans;
    }
    public static long fact(int n){
        long ans=1;
        for(int i=1;i<=n;i++){
            ans*=i;
        }
        return ans;
    }
}