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

public class Code3B {

    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        System.out.println(optMaxProd(N));
    }

    public static int optMaxProd(long N){
        String num = String.valueOf(N);
        char[] nums = num.toCharArray();
        int max = 1;

        for (int i = 0; i < nums.length; i++) {
            max*= nums[i] - '0';
        }

        for(int i = 0; i < nums.length; i++){
            int prod = 1;

            long leftNum = Long.valueOf(num.substring(0, i+1));
            leftNum--;
            if(leftNum != 0){
                String str = String.valueOf(leftNum);
                for(char c : str.toCharArray()){
                    prod*= c - '0';
                }
            }

            for(int j = i+1; j < nums.length; j++){
                prod*=9;
            }


            if(prod > max){
                max = prod;
            }
        }
        return max;
    }

    //посчитать кол-во единиц непрерывных
    public static int maxprod(int n){
        int max = 1, num = 1;
        for(int i = 1; i <= n; ++i){
           int prod = prod(i);
           if(prod > max){
               max = prod;
               num = i;
           }
        }
        return max;

    }

    public static int prod(int n){
        int prod = 1;
        while(n != 0){
            prod*= n % 10;
            n/=10;
        }
        return prod;
    }

}