eolymp
bolt
Try our new interface for solving problems
Problems

Cow Dance Show

Cow Dance Show

After several months of rehearsal, the cows are just about ready to put on their annual dance performance; this year they are performing the famous bovine ballet "Cowpelia".

The only aspect of the show that remains to be determined is the size of the stage. A stage of size k can support k cows dancing simultaneously. The n cows in the herd are conveniently numbered 1 .. n in the order in which they must appear in the dance. Each cow i plans to dance for a specific duration of time d(i). Initially, cows 1 .. k appear on stage and start dancing. When the first of these cows completes her part, she leaves the stage and cow k + 1 immediately starts dancing, and so on, so there are always k cows dancing (until the end of the show, when we start to run out of cows). The show ends when the last cow completes her dancing part, at time t.

Clearly, the larger the value of k, the smaller the value of t. Since the show cannot last too long, you are given as input an upper bound Tmax specifying the largest possible value of t. Subject to this constraint, please determine the smallest possible value of k.

Input

The first line contains n (1n10000) and Tmax, where Tmax is an integer of value at most 1 million. The next n lines give the durations d(1) .. d(n) of the dancing parts for cows 1 .. n. Each d(i) value is an integer in the range 1 .. 105.

It is guaranteed that if k = n, the show will finish in time.

Output

Print out the smallest possible value of k such that the dance performance will take no more than Tmax units of time.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 8
4
7
8
6
4
Output example #1
4
Source 2017 USACO January, Silver