Олимпиадный тренинг

Задача 43137. Time to go home


Задача

Темы:
One autumn day, the Chebarkul American football team was returning home by train after a friendly match with the Cheboksary team. Approaching the next river, the head coaches of the football players — Alexey Yurievich and Mikhail Leonidovich — noticed that the bridge across the river on their way does not look too reliable, and if several wagons with a total mass of more than W tons are entirely on it, the crossing will surely collapse. Cars that are not completely on the bridge are not counted in the total mass.
Aleksey Yurievich, as the most responsible coach, knows exactly how much each of the train cars weighs: the i-th car from the beginning of the train has a mass of ai tons. Mikhail Leonidovich, on the other hand, has perfect eyesight, and therefore he can say that the length of the bridge is equal to the length of exactly p cars.
Crashes cannot be allowed in any way, and therefore the coaches made a strong-willed decision: to unhook the minimum number of cars (perhaps all) from the end of the train so that the train could pass a dangerous place. Help them and tell them how many wagons they will have to leave before the crossing.
Input
The first line of the input contains three space-separated integers n,p and W — the number of cars in the train, the length of the bridge in cars and the maximum load in tons it can support (1 <= n <= 105, 1 <= p <=105 , 0 <= W <=1014).
The second line contains n space-separated integers ai — wagon weights in their order from the beginning of the train (1 <= ai <= 109).
Imprint
Print a single number — the minimum number of cars that must be unhooked from the tail of the train so that it can safely pass over the bridge.
 
Examples
# Input Output
1 4 2 10
5 3 4 8
1

Remark
In this test, the bridge will collapse only if the 3rd and 4th cars hit it at the same time, which means that it is enough to unhook only the last car.