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).
def obter_produto(n):
    prod = 1
    for i in n:
        prod *= i
    return prod

def contem_zero(n):
    for i in n:
        if i == 0:
            return True
    return False

def acha_zero(n): #retorna o zero mais ao final da lista passada
    for i in range(len(n))[::-1]:
        if n[i]==0:
            return i
    return -1

def copy_list(l1):
    l2 = []
    for i in l1:
        l2.append(i)
    return l2

n = list( str(int(input())) )#fazo esse string int para retirar leading zeros
n.reverse()
for i in range(len(n)):
    n[i] = int(n[i])
#print(n)

if contem_zero(n):
    #print('tem zero')
    #procedimento para zeros
    pos_zero = acha_zero(n)
    n[pos_zero+1] -= 1
    for i in range(pos_zero+1):
        n[i] = 9
    #print(pos_zero)
    #print(n)
    #deleting possible leading zeros
    if n[-1] == 0:
        del n[-1]
    #print(n)

#procedimento padrao
prod = obter_produto(n)
n2 = copy_list(n)
n_final = copy_list(n)
for i in range(1, len(n)):
    n2[i] -= 1
    n2[i-1] = 9
    # deleting possible leading zeros
    if n2[-1] == 0:
        del n2[-1]
    prod2 = obter_produto(n2)
    if prod2 > prod:
        prod = prod2
        #retiravel
        n_final = copy_list(n2)

#complemento do retiravel
n_final.reverse()
#print(n_final)

print(prod)
			   		  	  				 			 		   				