{"raw_statement":[{"iden":"statement","content":"Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.\n\nOne day Petya came across a positive integer _n_. Help him to find the least super lucky number which is not less than _n_."},{"iden":"input","content":"The only line contains a positive integer _n_ (1 ≤ _n_ ≤ 109). This number doesn't have leading zeroes."},{"iden":"output","content":"Output the least super lucky number that is more than or equal to _n_.\n\nPlease, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator."},{"iden":"examples","content":"Input\n\n4500\n\nOutput\n\n4747\n\nInput\n\n47\n\nOutput\n\n47"}],"translated_statement":[{"iden":"statement","content":"Petya 喜欢幸运数字。众所周知，正整数如果其十进制表示中不包含除 #cf_span[4] 和 #cf_span[7] 以外的数字，则被称为 #cf_span(class=[tex-font-style-underline], body=[lucky])。例如，数字 #cf_span[47]、#cf_span[744]、#cf_span[4] 是幸运的，而 #cf_span[5]、#cf_span[17]、#cf_span[467] 则不是。\n\n如果一个幸运数的十进制表示中包含相等数量的数字 #cf_span[4] 和 #cf_span[7]，则称其为 #cf_span(class=[tex-font-style-underline], body=[super lucky])。例如，数字 #cf_span[47]、#cf_span[7744]、#cf_span[474477] 是超级幸运的，而 #cf_span[4]、#cf_span[744]、#cf_span[467] 则不是。\n\n一天，Petya 遇到了一个正整数 #cf_span[n]。请帮他找出不小于 #cf_span[n] 的最小超级幸运数。\n\n输入仅包含一行，一个正整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 109]）。该数不包含前导零。\n\n请输出不小于 #cf_span[n] 的最小超级幸运数。\n\n请注意，在 C++ 中不要使用 %lld 特定格式符来读写 64 位整数。推荐使用 cin、cout 流，或使用 %I64d 特定格式符。"},{"iden":"input","content":"输入仅包含一行，一个正整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 109]）。该数不包含前导零。"},{"iden":"output","content":"请输出不小于 #cf_span[n] 的最小超级幸运数。请注意，在 C++ 中不要使用 %lld 特定格式符来读写 64 位整数。推荐使用 cin、cout 流，或使用 %I64d 特定格式符。"},{"iden":"examples","content":"输入\n4500\n输出\n4747\n\n输入\n47\n输出\n47"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ S $ be the set of *super lucky* numbers:  \n$$ S = \\left\\{ m \\in \\mathbb{Z}^+ \\mid \\text{decimal representation of } m \\text{ contains only digits } 4 \\text{ and } 7, \\text{ and } \\#_4(m) = \\#_7(m) \\right\\} $$  \nwhere $ \\#_d(m) $ denotes the count of digit $ d $ in the decimal representation of $ m $.\n\n**Constraints**  \nGiven $ n \\in \\mathbb{Z}^+ $ such that $ 1 \\leq n \\leq 10^9 $.\n\n**Objective**  \nFind the minimum $ m \\in S $ such that $ m \\geq n $.","simple_statement":null,"has_page_source":false}