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).

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
/**
 *
 * @author yijieren
 */
public class Test {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        /*
        Scanner scn = new Scanner(System.in);
        String line1 = scn.nextLine();
        String line2 = scn.nextLine();
        String[] t1 = line1.split(":");
        String[] t2 = line2.split(":");
        scn.close();
        
        int h1 = Integer.parseInt(t1[0]);  
        int m1 = Integer.parseInt(t1[1]);  
        int h2 = Integer.parseInt(t2[0]);
        int m2 = Integer.parseInt(t2[1]);
        */
        
        /*
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt(); 
        scn.close();
        */
        
        Scanner scn = new Scanner(System.in);
        String string = scn.nextLine();
        scn.close();
        
        char[] digits = string.toCharArray();
        int result = 1;
        
        for(char c : digits){
            result *= c-'0';
        }
        
        for(int i=0; i<digits.length; i++){
            if(digits[i] == '0')
                continue;
            
            char[] curr = Arrays.copyOf(digits, digits.length);
            int cur = curr[i] - '0' - 1;
            curr[i] = Character.forDigit(cur, 10);
            
            for(int j=i+1; j<curr.length; j++)
                curr[j] = '9';
            
            int num = 1;
            for(int k=0; k<curr.length; k++){
                if(k == 0 && curr[k] == '0')
                    continue;
                num *= curr[k]-'0';
            }
            
            
            result = Math.max(num, result);
            
        }
        
        /*
        Scanner scn = new Scanner(System.in);
        String line1 = scn.nextLine();
        String line2 = scn.nextLine();
        String[] door = line2.split(" ");
        scn.close();
        
        int n = Integer.parseInt(line1);
        int[] arr = new int[n];
        for(int i=0; i<n; i++){
            arr[i] = Integer.parseInt(door[i]);
        }
        */
        
        
        /*
        Scanner scn = new Scanner(System.in);
        String line1 = scn.nextLine();
        String s = scn.nextLine();
        int n = Integer.parseInt(line1);
        */
        
        System.out.println(result);
    }
    
}
