817C.md (1463B)
1 Source: https://codeforces.com/problemset/problem/817/C 2 3 C. Really Big Numbers 4 5 time limit per test 6 7 1 second 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 Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number *x* is really big if the difference between *x* and the sum of its digits (in decimal representation) is not less than *s*. To prove that these numbers may have different special properties, he wants to know how rare (or not rare) they are — in fact, he needs to calculate the quantity of really big numbers that are not greater than *n*. 22 23 Ivan tried to do the calculations himself, but soon realized that it's too difficult for him. So he asked you to help him in calculations. 24 25 Input 26 27 The first (and the only) line contains two integers *n* and *s* (1 ≤ *n*, *s* ≤ 1018). 28 29 Output 30 31 Print one integer — the quantity of really big numbers that are not greater than *n*. 32 33 Examples 34 35 Input 36 37 ``` 38 12 1 39 ``` 40 41 Output 42 43 ``` 44 3 45 ``` 46 47 Input 48 49 ``` 50 25 20 51 ``` 52 53 Output 54 55 ``` 56 0 57 ``` 58 59 Input 60 61 ``` 62 10 9 63 ``` 64 65 Output 66 67 ``` 68 1 69 ``` 70 71 Note 72 73 In the first example numbers 10, 11 and 12 are really big. 74 75 In the second example there are no really big numbers that are not greater than 25 (in fact, the first really big number is 30: 30 - 3 ≥ 20). 76 77 In the third example 10 is the only really big number (10 - 1 ≥ 9).