Greatest Product

No attempts yetTime limit1sMemory limit128 MB

Problem

September 10th is Forest Day. To celebrate, the dwellers of the Magic Forest decided to throw a party, and Kuzma the beaver was put in charge of the intellectual games. The rules of the game Kuzma invented are simple.

The host announces a positive integer NN. For every positive integer from 11 to NN, the player computes the product of that integer's digits, and must report the greatest such product.

To run the game smoothly, all answers must be known in advance. This is tricky because NN can be fairly large (1N20000000001 \le N \le 2000000000). Since Kuzma is not comfortable with computers, write a program that, given a positive integer NN, finds the correct answer.

In other words, over all integers kk with 1kN1 \le k \le N, output the maximum possible product of the digits of kk.

Input

Each line of the input contains one integer NN. The input may span several lines until end of file (EOF). (1N20000000001 \le N \le 2000000000)

Output

For each NN, print on the corresponding line the greatest digit product among the integers from 11 to NN.