Saqqa became jealous of Apple and wanted to visit Hammoudeh's home as well, but unfortunately, his home was too far, so he decided to take the shortest path, which needed Husam's Prius then some parkour. He asked MEOW to give him a test so he can determine how good his parkour skills are.
There are $n$ buildings. The height of the $i^{th}$ building is $a_i$.
Saqqa's initial strength is $k$. When he climbs a building of height $h$, his strength will decrease by $h$. After Saqqa climbs a building, MEOW will increase its height by $a_i$ (its initial height) to make climbing harder.
Saqqa will start climbing the leftmost building and keep climbing the buildings one by one until he reaches the rightmost building. Then he will change directions and climb until he reaches the leftmost building, and so on until his strength is no longer enough for him to keep climbing.
Find the number of buildings that Saqqa will be able to climb. In other words, the number of buildings that he can climb before his strength becomes less than the next building's height.
The first line of input contains $2$ integers, $n$ and $k$, the number of buildings and Saqqa's initial strength respectively, where ($1 \leq n \leq 10^5$) and ($1 \leq k \leq 10^{18}$).
The second line contains $n$ integers $a_1,\space a_2,\space ...,\space a_n$ ($1 \leq a_i \leq 10^5$), the initial heights of the buildings.
Output a single integer, the number of buildings that Saqqa can climb before his strength is no longer enough for him to keep climbing.
The first example will go as follows:
Here, he will stop because his strength is less that the height is the second building ($2 < 6$) so he cannot climb it.
Input | Output |
---|---|
3 22 2 3 5 Copy
|
4 Copy
|
1 10 1 Copy
|
4 Copy
|