eolymp
bolt
Try our new interface for solving problems
Problems

Greatest Product

Greatest Product

September 10th is forester day. On this occasion Magic forest dwellers decided to make a party. Kuzma beaver is assigned to take care about intellectual games. Kuzma has invented at his opinion quite interesting game. Rules of the game are simple. Master announces positive integer \textbf{N}. Player needs to calculate product of digits for each positive integer up to N and report the greatest product. All answers should be known beforehand to allow interactive communication during a game. This causes problems since \textbf{N} could be relatively big (\textbf{1} ≤ \textbf{N} ≤ \textbf{2000000000}). Kuzma is not good using computers; he asks you to write a program which having positive integer \textbf{N} will find correct answer. \InputFile Each line at input contains integer \textbf{N}. \OutputFile Corresponding line at output should contain greatest product for this \textbf{N}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
Output example #1
1