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 {

    public String s;

    public int[][] cache1;
    public int[][] cache2;

    public int dp(int n, int k) {
        if (n == -1) {
            return 1;
        }
        if (cache1[n][k] != -1) {
            return cache1[n][k];
        }
        int maxAns = 0;
        for (int prevD = 0; prevD < 10; prevD++) {
            maxAns = Math.max(maxAns, dp(n - 1, prevD) * k);
        }
        cache1[n][k] = maxAns;
        return maxAns;
    }

    public int dp2(int n, int k) {
        if (n == -1) {
            return 1;
        }
        if (cache2[n][k] != -1) {
            return cache2[n][k];
        }
        int maxAns = 0;
        if (s.charAt(n) - '0' > k) {
            for (int prevD = 0; prevD < 10; prevD++) {
                maxAns = Math.max(maxAns, dp(n - 1, prevD) * k);
            }
        }
        for (int prevD = 0; prevD < 10; prevD++) {
            maxAns = Math.max(maxAns, dp2(n - 1, prevD) * (s.charAt(n) - '0'));
        }
        cache2[n][k] = maxAns;
        return maxAns;
    }

    public void solve() throws IOException {
        int x = nextInt();
        s = new StringBuilder(Integer.toString(x)).reverse().toString();
        int n = s.length();
        cache1 = new int[n][10];
        cache2 = new int[n][10];
        for (int i = 0; i < n; i++) {
            Arrays.fill(cache1[i], -1);
            Arrays.fill(cache2[i], -1);
        }
        int ans = 0;
        for (int d = 0; d < 10; d++) {
            ans = Math.max(ans, dp2(n - 1, d));
        }
        for (int len = n - 2; len >= 0; len--) {
            for (int d = 0; d < 10; d++) {
                ans = Math.max(ans, dp(len, d));
            }
        }
        out.println(ans);
    }

    public void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

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

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

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

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

    public static void main(String... args) throws IOException {
        new B().run();
    }
}
