1701.The number on the board

Time Limit: 1s Memory Limit: 256MB

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 Format(From the terminal/stdin)

The first line contains integer k (1 \le k \le 109).

The second line contains integer n (1 \le n \lt 10100000).

There are no leading zeros in n. It's guaranteed that this situation is possible.

Output Format(To the terminal/stdout)

Print the minimum number of digits in which the initial number and n can differ.

Sample Input 1

Copy
3
11
 \n
  \n

Sample Output 1

Copy
1
 \n

Sample Input 2

Copy
3
99
 \n
  \n

Sample Output 2

Copy
0
 \n

Hints

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.

Submit

请先 登录

© 2025 FAQs