835B.md (1126B)
1 Source: https://codeforces.com/contest/835/problem/B 2 3 B. The number on the board 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 You have to find the minimum number of digits in which these two numbers can differ. 24 25 Input 26 27 The first line contains integer *k* (1 ≤ *k* ≤ 109). 28 29 The second line contains integer *n* (1 ≤ *n* < 10100000). 30 31 There are no leading zeros in *n*. It's guaranteed that this situation is possible. 32 33 Output 34 35 Print the minimum number of digits in which the initial number and *n* can differ. 36 37 Examples 38 39 Input 40 41 ``` 42 3 43 11 44 ``` 45 46 Output 47 48 ``` 49 1 50 ``` 51 52 Input 53 54 ``` 55 3 56 99 57 ``` 58 59 Output 60 61 ``` 62 0 63 ``` 64 65 Note 66 67 In the first example, the initial number could be 12. 68 69 In the second example the sum of the digits of *n* is not less than *k*. The initial number could be equal to *n*.