{"raw_statement":[{"iden":"statement","content":"Anton has the integer _x_. He is interested what positive integer, which doesn't exceed _x_, has the maximum sum of digits.\n\nYour task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them."},{"iden":"input","content":"The first line contains the positive integer _x_ (1 ≤ _x_ ≤ 1018) — the integer which Anton has."},{"iden":"output","content":"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."},{"iden":"examples","content":"Input\n\n100\n\nOutput\n\n99\n\nInput\n\n48\n\nOutput\n\n48\n\nInput\n\n521\n\nOutput\n\n499"}],"translated_statement":[{"iden":"statement","content":"Anton 有一个整数 #cf_span[x]。他想知道一个不超过 #cf_span[x] 的正整数，其各位数字之和最大。\n\n你的任务是帮助 Anton 找到这个整数。如果有多个这样的整数，请找出其中最大的一个。\n\n第一行包含一个正整数 #cf_span[x]（#cf_span[1 ≤ x ≤ 1018]）——Anton 拥有的整数。\n\n请输出一个不超过 #cf_span[x] 且各位数字之和最大的正整数。如果有多个这样的整数，请输出其中最大的一个。输出的整数不能包含前导零。\n\n"},{"iden":"input","content":"第一行包含一个正整数 #cf_span[x]（#cf_span[1 ≤ x ≤ 1018]）——Anton 拥有的整数。 "},{"iden":"output","content":"请输出一个不超过 #cf_span[x] 且各位数字之和最大的正整数。如果有多个这样的整数，请输出其中最大的一个。输出的整数不能包含前导零。"},{"iden":"examples","content":"输入\n100\n输出\n99\n输入\n48\n输出\n48\n输入\n521\n输出\n499"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ x \\in \\mathbb{Z} $ with $ 1 \\leq x \\leq 10^{18} $.  \nLet $ S(n) = \\sum_{i=0}^{k} d_i $ denote the sum of digits of a positive integer $ n $, where $ n = \\sum_{i=0}^{k} d_i \\cdot 10^i $ and $ d_i \\in \\{0,1,\\dots,9\\} $, $ d_k \\neq 0 $.  \n\n**Constraints**  \nFind $ n \\in \\mathbb{Z} $ such that:  \n1. $ 1 \\leq n \\leq x $  \n2. $ S(n) $ is maximized over all such $ n $  \n3. If multiple $ n $ achieve the maximum $ S(n) $, choose the largest such $ n $  \n\n**Objective**  \nDetermine $ \\max \\left\\{ n \\in \\mathbb{Z} \\mid 1 \\leq n \\leq x \\text{ and } S(n) = \\max_{1 \\leq m \\leq x} S(m) \\right\\} $","simple_statement":null,"has_page_source":false}