跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0900. Maximize Sum of Digits

    ID: 906 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟数学编程与模拟基础难度共享题库Codeforces英文题面题目来源题面语言

Maximize Sum of Digits

题目描述

B. Maximize Sum of Digits
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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≤1018) − 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.

Examples
Input
100
Output
99
Input
48
Output
48
Input
521
Output
499


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 333 题。保留原作者与原赛事署名。