eolymp
bolt
Try our new interface for solving problems
Problems

Максимум

Максимум

Recently, a first grader learned to add numbers Vasya. It this process very much, and he puts everything in sight. When all the numbers are stacked around, Vasili turned to his older brother Pete for new numbers. After several appeals tired of working random number generator, Peter came up to Washi task that can also take a long time. He suggested Vasya find the sum of digits of consecutive numbers --- \textbf{1}, \textbf{2}, \textbf{3}, \textbf{4}, \textbf{5}, \textbf{6}, \textbf{7}, \textbf{8}, \textbf{9}, \textbf{10}, \textbf{11}, \textbf{12}, \textbf{13}, \textbf{14}, \textbf{15}, \textbf{16}, \textbf{17}, \textbf{18}, \textbf{19}, \textbf{20}, \textbf{21} --- and so on, until Vasya not get bored. Vasya was enthusiastic about the idea and went to work. Yesterday Vasya find sum of digits of each of the numbers from \textbf{1} to \textbf{115}. Looking at the results of his younger brother, Peter noticed that the sum of digits of consecutive numbers are not random, often they are consecutive, but the pattern completely, he did not understand. To find the patterns, Peter decided to explore the extreme cases, for example, which of the numbers gives the maximum amount of digits. Data for the numbers to \textbf{115} was not enough for final conclusions, and Pete had the idea to speed up the calculations used in place of brother computer. As he himself programming is not very strong, he sought the solution of this problem to you. \InputFile In the first line of input data is the number \textbf{N} (\textbf{1} <= \textbf{N} <= \textbf{2 147 483 647}). \OutputFile Remove a number from \textbf{1} to \textbf{N} inclusive, with the maximum amount of digits. If the numbers with a maximum sum of several numbers, display the greatest of them.
Time limit 1 second
Memory limit 64 MiB
Input example #1
115
Output example #1
99