VK Cup 2017 - Qualification 2
B
Maximize Sum of Digits
Codeforces
1300
原题
← AC →
翻译中…

Anton has the integer $*x*$. He is interested what positive integer, which doesn't exceed $*x*$, has the maximum sum of digits.

翻译中…

Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them.

翻译中…

Input

翻译中…

The first line contains the positive integer $*x*$ ($1 ≤ *x* ≤ 10^{18}$) — the integer which Anton has.

翻译中…

Output

翻译中…

Print the positive integer which doesn't exceed $*x*$ and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros.

翻译中…

样例

Input #1
100
Output #1
99
InputCopy OutputCopy
Input #2
48
Output #2
48
InputCopy OutputCopy
Input #3
521
Output #3
499
InputCopy OutputCopy
题目信息
题号
770B
时间限制
1 s
内存限制
256 MB
标签
*special
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。