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

public class Nirvana {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		if(n < 10) {
			System.out.println(n);
			return;
		}
		int digits = getDigits(n);
		int max = (int) Math.pow(9, digits - 1);
		String s = n + "";
		int curr = Integer.parseInt(s.charAt(0) + "");
		int i = 1;
		max = Math.max(max, (curr - 1) * (int) Math.pow(9, digits - i));
//		System.out.println(max);
		while(i < digits) {
			max = Math.max(max, (curr) * (Integer.parseInt(s.charAt(i) + "") - 1) * (int) Math.pow(9, digits - i - 1));
			curr *= Integer.parseInt(s.charAt(i) + "");
			i++;
		}
		int l = 1;
		for(int k = 0; k < digits; k++) {
			l *= Integer.parseInt(s.charAt(k) + "");
		}
		max = Math.max(max, l);
		System.out.println(max);
	}
	public static int getDigits(int n) {
		int digits = 0;
		while(n > 0) {
			n /= 10;
			digits++;
		}
		return digits;
	}
	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

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