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 random
import time

seed = int(time.time())
random.seed(seed)

def digit_prod(n):
    acc = 1
    for c in str(n):
        acc *= int(c)
    return acc

def solve2(n, n_str, l):
    best = digit_prod(n)
    best_num = n
    for i in range(1, l):
        prefix = n_str[:i]
        prefix_m_1 = str(int(prefix)-1) if int(prefix) > 1 else ''
        suffix = '9'*(l-i)
        cur = digit_prod(prefix_m_1 + suffix)
        if cur > best:
            best = cur
            best_num = prefix_m_1 + suffix
    return best

def solve(n, n_str, l):
    if l == 1:
        return n

    max_nm1 = 9**(l-1)
    base_nm2 = 9**(l-2)
    self = reduce(lambda acc, x: acc*int(x), n_str, 1)
    f2m1 = str(int(n_str[:2])-1)
    max2 = int(f2m1[0])*int(f2m1[1])*base_nm2 if len(f2m1) > 1 else 0
    max3 = (int(n_str[0])-1)*max_nm1
    end_in_9 = n
    while end_in_9 % 10 != 9:
        end_in_9 -= 1
    max4 = reduce(lambda acc, x: acc*int(x), str(end_in_9), 1)

    return max(max_nm1, max2, max3, max4, self)

def solve_slow(n):
    best = 0
    for i in range(1, n+1):
        si = str(i)
        pi = reduce(lambda acc, x: acc*int(x), si, 1)
        best = max(best, pi)
    return best

def main():
    n_str = raw_input().strip()
    l = len(n_str)
    n = int(n_str)
    print solve2(n, n_str, l)

if '__main__'==__name__:
    main()
