It is the night after Christmas, and there are leftover candies to distribute. In addition, there are reindeer who would like to have candy. However, each reindeer would like to have at least candies to be "satisfied."
There might not be enough candies to make all the reindeer happy, but can you help Santa figure out the maximum number of reindeer he can satisfy by distributing the candies?
Constraints
Subtask 1 [20%]
for all .
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains two space-separated integers, and , respectively.
The next lines contain one integer each, the -th representing .
Output Specification
Output one integer, the maximum number of reindeer Santa can satisfy.
Sample Input 1
5 3
1
1
1
1
1
Sample Output 1
3
Explanation for Sample Output 1
Since there are only candies to distribute, and each of the reindeer wants candy at minimum, Santa can only satisfy a maximum of reindeer before running out of candy.
Sample Input 2
5 10
3
2
5
1
6
Sample Output 2
3
Explanation for Sample Output 2
If Santa gives candies to the 1st, 2nd, and 4th reindeer, he uses up a total of candies. With candies remaining, he cannot satisfy the other reindeers because they need at least or candies.
Hence, the maximum number of reindeer that can be satisfied is .
Comments