In a magical world, pigs live under the constant threat of wolves. Thus, the pigs have developed an elevator to escape from the wolves.
One day, right before a wolf raid, there are pigs in a queue waiting for the elevator, with the
pig having weight
. The elevator has a weight limit
.
Since the pigs have a bit of time before the wolf raid, at most one pig in the queue can step out and re-enter the queue at a different position.
What is the largest number of pigs that can fit onto the elevator without exceeding the weight limit?
Constraints
Input Specification
The first line contains two integers and
.
The second line of input consists of integers
.
Output Specification
Output the largest number of pigs that can fit on the elevator if at most one pig changes their place.
Sample Input 1
6 11
2 4 5 2 1 6
Sample Output 1
4
Explanation for Sample Output 1
If the second pig in the queue moves to the end of the queue, then pigs can enter the elevator, whose weight are
,
,
, and
, in order.
Sample Input 2
6 6
5 4 5 2 1 1
Sample Output 2
2
Sample Input 3
6 1000000000000
1 2 3 4 5 6
Sample Output 3
6
Comments