Description
Problem Statement
There are NN weights called Weight 11, Weight 22, \dots…, Weight NN. Weight ii has a mass of A_iAi.
Let us say a positive integer nn is a good integer if the following condition is satisfied:
-
We can choose at most 33 different weights so that they have a total mass of nn.
How many positive integers less than or equal to WW are good integers?
Constraints
-
1 \leq N \leq 3001≤N≤300
-
1 \leq W \leq 10^61≤W≤106
-
1 \leq A_i \leq 10^61≤Ai≤106
-
All values in input are integers.
Input
Input is given from Standard Input in the following format:
NNWWA_1A1A_2A2\dots…A_NAN
Output
Print the answer.
HINT
If we choose only Weight 11, it has a total mass of 11, so 11 is a good integer.
If we choose only Weight 22, it has a total mass of 33, so 33 is a good integer.
If we choose Weights 11 and 22, they have a total mass of 44, so 44 is a good integer.
No other integer is a good integer. Also, all of 11, 33, and 44 are integers less than or equal to WW. Therefore, the answer is 33.