Some natural number was written on the board. Its sum of digits was not less than k. But…
- User
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.
You have to find the minimum number of digits in which these two numbers can differ. Input
The first line contains integer k (1 ≤ k ≤ 109).
The second line contains integer n (1 ≤ n < 10100000).
There are no leading zeros in n. It's guaranteed that this situation is possible.
Output
Print the minimum number of digits in which the initial number and n can differ.
Examples
Input
3 11
Output
1
Input
3 99
Output
0
Note
In the first example, the initial number could be 12.
In the second example the sum of the digits of n is not less than k. The initial number could be equal to n.
Assistant
pythonk = int(input()) n = input().strip() sum_digits = sum(int(c) for c in n) if sum_digits >= k: print(0) else: required = k - sum_digits gains = [9 - int(c) for c in n] gains.sort(reverse=True) total = 0 count = 0 for gain in gains: if total >= required: break if gain <= 0: break total += gain count += 1 print(count)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.