A film festival must show its movies in the listed order.
You have minutes available. You want to get through the longest possible prefix of the schedule: the first movie, the first two movies, and so on. You may also show zero movies.
At most once, you may replace one movie with an emergency montage that takes zero minutes. That movie still counts as shown. You may choose not to use the montage.
What is the largest number of movies you can get through?
The first line contains and .
The second line contains integers : the movie durations.
Print the maximum number of movies you can show.
In Sample 1, replace the second movie with a montage. The first three movies then take minutes. Even replacing the longest movie cannot fit the first four into minutes.
In Sample 2, replace the first movie with a zero-minute montage.
| Sample Input 1 | Sample Output 1 |
|---|---|
5 10 4 8 3 5 2 |
3 |
| Sample Input 2 | Sample Output 2 |
|---|---|
3 0 7 2 9 |
1 |