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.*;
import java.util.*;

public class B {
    static long multiply(String s){
        long res = 1;
        int i=0;
        for(;i<s.length();i++){
            if(s.charAt(i)!='0')break;
        }
        for(;i<s.length();i++){
            res*=(s.charAt(i)-'0');
        }
        return res;
    }
    static ArrayList<ArrayList<Integer>>adjmat = new ArrayList<>();
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        long max = multiply(n+"");
        for(int i=0;i<(n+"").length();i++){
            String res = "";
            int j =0;
            for(;j<i;j++){
                res += Integer.parseInt((n + "").charAt(j) + "");
            }
            if(Integer.parseInt((n+"").charAt(j)+"")>0) {
                res += Integer.parseInt((n + "").charAt(j) + "") - 1;
                j++;
                for(;j<(n+"").length();j++){
                    res+="9";
                }
                //System.out.println(res);
            }


            max = Math.max(multiply(res),max);

        }
        pw.println(max);
        pw.flush();
        pw.close();
    }

    static class Pair implements Comparable<Pair>{
        long x;
        int index;
        public Pair(long x,int index){
            this.x= x;
            this.index = index;
        }
        public int compareTo(Pair p){
            if(this.x==p.x)return Integer.compare(this.index,p.index);
            return Long.compare(this.x,p.x);
        }

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();

        }
    }
}
