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.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
 * 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.
 */
/**
 *
 * @author NamBC
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException {
        // TODO code application logic here
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
//        InputStream inputStream = new FileInputStream("sample-A.2.in");
//        OutputStream outputStream = new FileOutputStream("sample-A.2.ou");
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    public static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long sol = 1;
            long product = 1;
            String s = String.valueOf(n);
            int length = s.length();
            if (length == 1) {
                out.print(n);
                return;
            }
            for (int i = 0; i < s.length(); i++) {
                int d = s.charAt(i) - 48;
                StringBuilder sb = new StringBuilder();
                if (d == 0) {
                    product = 1;
                    for (int j = 0; j < i - 1; j++) {
                        product *= (s.charAt(j) - 48);
                    }
                    product *= (s.charAt(i - 1) - 49);
                    product *= Math.pow(9, length - i);
                } else {
                    if (i == length - 1) {
                        product = d;
                    } else {
                        product = d - 1;
                    }
                    if (i == 0 && product == 0) {
                        product = (long) Math.pow(9, length - 1);
                    } else {
                        for (int j = 0; j < i; j++) {
                            product *= s.charAt(j) - 48;
                        }
                        product *= (long) Math.pow(9, length - i - 1);
                    }

                }

                if (sol < product) {
                    sol = product;
                }
            }
            out.print(sol);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}
