#abc251b. [abc251_b]At Most 3 (Judge ver.)
[abc251_b]At Most 3 (Judge ver.)
Problem Statement
There are weights called Weight , Weight , , Weight . Weight has a mass of .
Let us say a positive integer is a good integer if the following condition is satisfied:
- We can choose at most different weights so that they have a total mass of .
How many positive integers less than or equal to are good integers?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 10
1 3
Sample Output 1
3
If we choose only Weight , it has a total mass of , so is a good integer.
If we choose only Weight , it has a total mass of , so is a good integer.
If we choose Weights and , they have a total mass of , so is a good integer.
No other integer is a good integer. Also, all of , , and are integers less than or equal to . Therefore, the answer is .
Sample Input 2
2 1
2 3
Sample Output 2
0
There are no good integers less than or equal to .
Sample Input 3
4 12
3 3 3 3
Sample Output 3
3
There are good integers: , and .
For example, if we choose Weights , , and , they have a total mass of , so is a good integer.
Note that is not a good integer.
Sample Input 4
7 251
202 20 5 1 4 2 100
Sample Output 4
48