Reading at the Library


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

A library in Puerto Rico has n books arranged in a row. Reading book i takes a[i] minutes. You have t minutes before your next activity.

You may start at any book and read consecutive books to its right. You may not skip books or read them partially. Find the largest number of complete books you can read within t minutes. If you cannot read any book, answer zero.

Input

The first line contains n and t. The second contains n integers: a[1], a[2], …, a[n].

Output

Print one integer: the maximum number of books.

Constraints

1 ≤ n ≤ 100 000; 1 ≤ t ≤ 1 000 000 000; 1 ≤ a[i] ≤ 10 000.

Examples
Input Example Output Example
6 7
4 2 1 3 2 5
3
3 2
3 4 5
0

Books 2, 3 and 4 take 6 minutes. No consecutive block of four books fits within the available time.

No book can be read completely.

Source

Adapted for OiPR 2026. Codeforces 279B — Books.


Comments

There are no comments at the moment.