The UptoSkills CourierMedium

The UptoSkills Courier

Medium+40 XP · +15 Auraqueuesliding windowdeque

The UptoSkills Courier service has to deliver packages across the city. You are given the delivery times for n consecutive tasks, represented by an array t. The courier starts at task 0 and must complete tasks 0 to n-1 in order. A single courier can handle a batch of tasks if they are consecutive and the total time for the batch does not exceed a given limit k. Your goal is to find the maximum number of tasks a courier can deliver in a single batch, starting from task 0. That is, you want to find the largest L such that there exists a subarray t[0...L-1] whose sum is at most k.

Input

The first line contains two integers n and k (1 <= n <= 200000, 0 <= k <= 10^14). The second line contains n integers representing the delivery times t_i (0 <= t_i <= 10^9).

Output

Print a single integer: the maximum number of tasks L that can be delivered in a single batch starting from task 0.

Constraints

1 <= n <= 200000 0 <= k <= 10^14 0 <= t_i <= 10^9

Time limit 2 s (native code; slower languages get more)Memory 256 MB15 hidden tests

Example 1

Input
5 10
3 2 1 5 4
Output
3

The prefix sums are [0, 3, 5, 6, 11, 15]. The largest prefix sum <= 10 is 6 (for L=4). So, max L is 4.

Example 2

Input
3 0
1 1 1
Output
0

With k=0, only an empty batch (L=0) is possible if any delivery time is positive.

Hints