B - Digit Sum Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

正整数 n桁和を、 n を十進法で表したときの各桁の和と定めます。例えば 2026 の桁和は 2+0+2+6=10 です。

N 以下の正整数のうち、桁和が K であるものの個数を求めてください。

制約

  • 1\leq N,K \leq 10^5
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N K

出力

答えを出力せよ。


入力例 1

30 4

出力例 1

3

30 以下の正整数のうち、桁和が 4 であるものは、4,13,223 個です。


入力例 2

2026 10

出力例 2

121

入力例 3

99999 45

出力例 3

1

Score : 200 points

Problem Statement

The digit sum of a positive integer n is defined as the sum of the digits when n is represented in decimal. For example, the digit sum of 2026 is 2+0+2+6=10.

Find the number of positive integers not exceeding N whose digit sum is K.

Constraints

  • 1\leq N,K \leq 10^5
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N K

Output

Output the answer.


Sample Input 1

30 4

Sample Output 1

3

Among the positive integers not exceeding 30, there are three integers whose digit sum is 4: 4,13,22.


Sample Input 2

2026 10

Sample Output 2

121

Sample Input 3

99999 45

Sample Output 3

1