{"problem":{"name":"B. The number on the board","description":{"content":"Some natural number was written on the board. Its sum of digits was not less than _k_. But you were distracted a bit, and someone changed this number to _n_, replacing some digits with others. It's kn","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF835B"},"statements":[{"statement_type":"Markdown","content":"Some natural number was written on the board. Its sum of digits was not less than _k_. But you were distracted a bit, and someone changed this number to _n_, replacing some digits with others. It's known that the length of the number didn't change.\n\nYou have to find the minimum number of digits in which these two numbers can differ.\n\n## Input\n\nThe first line contains integer _k_ (1 ≤ _k_ ≤ 109).\n\nThe second line contains integer _n_ (1 ≤ _n_ < 10100000).\n\nThere are no leading zeros in _n_. It's guaranteed that this situation is possible.\n\n## Output\n\nPrint the minimum number of digits in which the initial number and _n_ can differ.\n\n[samples]\n\n## Note\n\nIn the first example, the initial number could be 12.\n\nIn the second example the sum of the digits of _n_ is not less than _k_. The initial number could be equal to _n_.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"某自然数被写在了黑板上，其各位数字之和不小于 $k$。但你稍一分心，有人将这个数改成了 $n$，用其他数字替换了部分数位。已知数字的长度没有改变。\n\n你需要找出这两个数在最少多少个数位上可能不同。\n\n第一行包含整数 $k$（$1 ≤ k ≤ 10^9$）。\n\n第二行包含整数 $n$（$1 ≤ n < 10^{100000}$）。\n\n$n$ 中没有前导零。保证这种情况是可能的。\n\n请输出初始数与 $n$ 可能不同的最少数位个数。\n\n在第一个例子中，初始数可能是 $12$。\n\n在第二个例子中，$n$ 的各位数字之和不小于 $k$，因此初始数可能等于 $n$。\n\n## Input\n\n第一行包含整数 $k$（$1 ≤ k ≤ 10^9$）。第二行包含整数 $n$（$1 ≤ n < 10^{100000}$）。$n$ 中没有前导零。保证这种情况是可能的。\n\n## Output\n\n请输出初始数与 $n$ 可能不同的最少数位个数。\n\n[samples]\n\n## Note\n\n在第一个例子中，初始数可能是 $12$。在第二个例子中，$n$ 的各位数字之和不小于 $k$，因此初始数可能等于 $n$。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ k \\in \\mathbb{Z} $ with $ 1 \\leq k \\leq 10^9 $ be the minimum required digit sum.  \nLet $ n $ be a string of decimal digits representing a positive integer with no leading zeros, and let $ |n| $ denote its length.  \nLet $ s(n) = \\sum_{i=1}^{|n|} d_i $ be the sum of the decimal digits of $ n $, where $ d_i $ is the $ i $-th digit.\n\n**Constraints**  \n1. $ 1 \\leq k \\leq 10^9 $  \n2. $ 1 \\leq |n| < 10^{100000} $ (i.e., $ n $ is a very long decimal string)  \n3. $ n $ has no leading zeros.  \n4. It is guaranteed that there exists a number $ m $ with $ |m| = |n| $ and $ s(m) \\geq k $, such that $ m $ differs from $ n $ in some digits.\n\n**Objective**  \nFind the minimum number of digit positions in which $ n $ and some number $ m $ (with $ |m| = |n| $ and $ s(m) \\geq k $) can differ.\n\nThat is, minimize $ |\\{ i \\mid n_i \\neq m_i \\}| $, subject to $ s(m) \\geq k $ and $ |m| = |n| $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF835B","tags":["greedy"],"sample_group":[["3\n11","1"],["3\n99","0"]],"created_at":"2026-03-03 11:00:39"}}