~/algor $ cat problems/dp-raqamlar-yigindisi-s
Numbers with digit sum S
Hard
1000 ms
128 MB
95%
A positive integer $N$ and an integer $S$ are given. How many numbers from $1$ to $N$ (inclusive) have a digit sum of exactly $S$?
Input
One line with two integers: $N$ and $S$.
Output
One integer — the count of such numbers.
Note
$1 \le N \le 10^{18}$
$0 \le S \le 162$
Examples
Input #1
100 10
Output #1
9
Input #2
9 9
Output #2
1