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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B {
    public static void main(String[] args) {
        FastIn in = FastIn.wrapSystemIn();
        int n = in.nextInt();
        System.out.println(maxprod(n));

    }

    static int maxprod(int n) {
        String s = String.valueOf(n);

        long max = digitProd(n);
        long nineProd = 1;
        for (int i = 0; i < s.length(); i++) {
            nineProd *= 9;
        }
        max = Math.max(max, 1);
        max = Math.max(max, nineProd / 9);
        for (int i = 0; i < s.length(); i++) {
            nineProd /= 9;
            int cur = Integer.parseInt(s.substring(0, i + 1)) - 1;
            long prodHere = digitProd(cur) * nineProd;
            max = Math.max(max, prodHere);
        }
        return (int) max;
    }

    static int digitProd(int n) {
        if (n == 0) {
            return 0;
        }
        int prod = 1;
        while (n > 0) {
            prod *= n % 10;
            n /= 10;
        }
        return prod;
    }



    static final class FastIn {
        private final BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        static FastIn wrapInputStream(InputStream inputStream) {
            return new FastIn(inputStream);
        }

        static FastIn wrapSystemIn() {
            return wrapInputStream(System.in);
        }

        private FastIn(InputStream inputStream) {
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            this.bufferedReader = new BufferedReader(inputStreamReader);
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        String nextString() {
            return nextToken();
        }

        int[] nextIntArrayOfSize(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        long[] nextLongArrayOfSize(int size) {
            long[] array = new long[size];
            for (int i = 0; i < size; i++) {
                array[i] = nextLong();
            }
            return array;
        }

        private String nextToken() {
            try {
                skipUntilNextTokenOrEndOfStream();
                assert hasNextToken();
                return stringTokenizer.nextToken();
            } catch (IOException ioException) {
                throw new RuntimeException(ioException);
            }
        }

        boolean hasNextToken() throws IOException {
            skipUntilNextTokenOrEndOfStream();
            return stringTokenizer.hasMoreTokens();
        }

        private void skipUntilNextTokenOrEndOfStream() throws IOException {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                String nextLine = bufferedReader.readLine();
                if (nextLine == null) {
                    return;
                }
                this.stringTokenizer = new StringTokenizer(nextLine);
            }
        }
    }
}