Decomposition of a Number
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Decompose the given natural number N into a sum of k natural numbers a_1, a_2, ..., a_k such that the sum of the digits of all these numbers, s(a_1) + s(a_2) + ... + s(a_k), equals the given natural number S. Additionally, the number of addends k should be minimized. Here, s(X) represents the sum of the digits in the decimal form of the natural number X.
Input
The first line contains an integer N (1 ≤ N ≤ 10^12), and the second line contains an integer S (1 ≤ S ≤ 10^12).
Output
Output an integer representing the minimal number of addends needed for the required decomposition. If no such decomposition exists where the sum of the digits of the addends equals S, output -1.
Examples
Input #1
Answer #1
Submissions 214
Acceptance rate 7%