LearnPy Hub
← Arena
AdvancedRating 1800

Numbers With Digit Sum s

Count the integers from 1 to n whose digits add up to exactly s.

Input

Two integers n (≤ 10¹⁸) and s (≤ 162).

Output

One integer.

Sample 1

Input
20 2
Output
3

Sample 2

Input
100 1
Output
3
solution.py
Output appears here
Numbers With Digit Sum s · Python Arena problem · LearnPy Hub