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 Main { 

static BufferedReader scanuxa; 

static { 
scanuxa = new BufferedReader((new InputStreamReader(System.in))); 
} 

static StringTokenizer stsuka; 


public static String tokenBlyat() throws Exception { 
while (stsuka == null || !stsuka.hasMoreTokens()) { 
stsuka = new StringTokenizer(scanuxa.readLine()); 
} 
return (stsuka.nextToken()); 
} 

public static int nextInt() throws Exception { 
return (Integer.parseInt(tokenBlyat())); 
} 

public static long nextLong() throws Exception { 
return (Long.parseLong(tokenBlyat())); 
} 

static int gluho(char[] str) 
{ 
int sushka = 0; 
for (int i = str.length - 1; i >= 0; i--) 
if (str[i] != '<') sushka++; 
else break; 

return sushka; 
} 

static int lp(char[] str) 
{ 
int count = 0; 
for (int i = 0; i < str.length; i++) 
if (str[i] != '>') count++; 
else break; 

return count; 
} 

public static void main(String[] args) throws Exception { 
//0=48 
long sushka=nextLong(),lg1=1,lg2=1,lg3=1,lg4=0; 
int n=0; 
String glock; 
char[]grach; 
glock=(sushka)+""; 
grach=glock.toCharArray(); 

for (long i = 9; lg4 + i < sushka; i *= 10) { 
lg1 *= 9; 
lg4 += i; 
n++; 
} 
while (lg4<=sushka) { 
if (n<0)break; 
if ((lg4+(int)Math.pow(10,n))<=sushka) { 
lg4 += (int) Math.pow(10, n); 
glock=(lg4)+""; 
grach=glock.toCharArray(); 
for (int i = 0; i < grach.length; i++) { 
lg2 *= (int) grach[i] - 48; 
if (lg2 == 0) break; 
} 
if (lg2 > lg3) lg3 = lg2; 
lg2 = 1; 
} 
else n--; 
} 
System.out.println(Math.max(lg1,lg3)); 


} 
}