B - アメの分配 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

問題文

正整数 N,C が与えられます。

高橋君はアメを N 個持っています。

高橋君は、N 個のアメを友達全員に均等に分けられるだけ分けたところ、手元には C 個のアメが余りました。

高橋君の友達の人数としてあり得る数は何通りか求めてください。

制約

  • 1\le N\le 100
  • 0 \le C < N
  • 入力は全て整数

入力

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

N C

出力

答えを出力せよ。


入力例 1

8 2

出力例 1

2

高橋君の友達が 3 人であった場合、高橋君は友達に 2 つずつアメを分けます。その結果、高橋君の手元には 2 個のアメが残ります。よって、高橋君の友達が 3 人である場合は条件を満たします。

高橋君の友達が 2 人であった場合、高橋君は友達に 4 つずつアメを分けます。その結果、高橋君の手元には 0 個のアメが残ります。よって、高橋君の友達が 2 人である場合は条件を満たしません。

条件を満たす高橋君の友達の人数は 3,6 人の 2 通りなので、 2 を出力してください。


入力例 2

7 3

出力例 2

1

高橋君の友達が 4 人であった場合、高橋君は友達に 1 つずつアメを分けます。その結果、高橋君の手元には 3 個のアメが残ります。よって、高橋君の友達が 4 人である場合は条件を満たします。

高橋君の友達が 2 人であった場合、手元に残るアメは 1 個になるので条件を満たさないことに注意してください。


入力例 3

5 4

出力例 3

0

条件を満たす友達の人数が存在しない場合もあります。


入力例 4

1 0

出力例 4

1

入力例 5

87 3

出力例 5

9

Problem Statement

You are given positive integers N and C.

Takahashi had N candies.

He equally distributed the N candies to his friends as many as possible, and now he has C candies left.

How many distinct values can be the number of his friends?

Constraints

  • 1\le N\le 100
  • 0 \le C < N
  • All input values are integers.

Input

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

N C

Output

Print the answer.


Sample Input 1

8 2

Sample Output 1

2

If he has 3 friends, he will distribute 2 candies each, leaving 2 candies. Thus, if he has 3 friends, the condition is satisfied.

If he has 2 friends, he will distribute 4 candies each, leaving 0 candies. Thus, if he has 2 friends, the condition is not satisfied.

There are two values applicable for the number of his friends: 3 and 6. Thus, print 2.


Sample Input 2

7 3

Sample Output 2

1

If he has 4 friends, he will distribute 1 candy each, leaving 3 candies. Thus, if he has 4 friends, the condition is satisfied.

If he has 2 friends, 1 candy will be left; note that this is not applicable.


Sample Input 3

5 4

Sample Output 3

0

There may be no applicable values.


Sample Input 4

1 0

Sample Output 4

1

Sample Input 5

87 3

Sample Output 5

9