520. Books
0
Easy
Valera has a certain amount of free time and a collection of books in the library. Each book has an estimated reading time. Valera wants to choose a starting book and read as many books as possible within his available free time. He will read each book in sequential order, starting from the chosen book, until he runs out of time or finishes reading all the books. Valera cannot start reading a book if he doesn't have enough time to finish it. Determine the maximum number of books Valera can read.
Input Format
The first line contains two positive integers N and T, separated by a space. N represents the number of books in the library, and T represents the available free time in minutes.
The second line contains N positive integers, separated by a space, representing the estimated reading time for each book.
Output Format
Print the maximum number of books Valera can read.
Example
Input
4 5
3 1 2 1
Output
3
Constraints
1 <= N <= 10^5
1 <= A[i] <= 10^4
1 <= T <= 10^9
Loading...
View Submissions
Console