{"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_ ≤ 10100000). This number doesn't have leading zeroes."},{"iden":"output","content":"Output the least super lucky number that is more than or equal to _n_."},{"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 ≤ 10100000]）。该数没有前导零。\n\n请输出不小于 #cf_span[n] 的最小超级幸运数。\n\n"},{"iden":"input","content":"仅一行包含一个正整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 10100000]）。该数没有前导零。"},{"iden":"output","content":"请输出不小于 #cf_span[n] 的最小超级幸运数。"},{"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}^+ $, with $ 1 \\leq n \\leq 10^{100000} $, and $ n $ has no leading zeros.\n\n**Objective**  \nFind $ \\min \\{ m \\in S \\mid m \\geq n \\} $.","simple_statement":null,"has_page_source":false}