14629 - KuoTA Restaurant 3   

Description

Elephants love to eat KuoTA (鍋貼), so Elfnt decided to open a restaurant called "八方來財", serving delicious KuoTA to satisfy their cravings.

Now that Elfnt knows how to calculate the duration the restaurant needs to stay open, he hopes to minimize his working hours. He already knows the dining time of all $n$ elephants today. Please help him determine the minimum number of seats required so that the restaurant can close within $k$ units of time (including $k$).

As long as there is an available seat, the customer at the front of the queue will immediately be seated and start dining. Once the $i$-th customer is seated, they will occupy the seat for $x_i$ units of time, after which they will leave the restaurant, freeing up the seat.

It is guaranteed that the answer must exists.

Input

The first line contains two integers $n$ and $k$, representing the number of elephants and the maximum allowed time units before the restaurant closes.

The second line contains $n$ integers $x_1, x_2, ..., x_n$, where $x_i$ is the amount of time the $i$-th elephant will take to dine.

Constraints

  • $1 \leq n \leq 2 \times 10^5$
  • $1 \leq x_i \leq 1000$
  • $1 \leq k \leq \sum_{i=1}^{n}x_i$

Subtask

  1. (Testcases 1-5) $1 \leq n \leq 1000$
  2. (Testcases 6-8) No additional constraints.

Output

Output the minimum number of seats required to ensure that all elephants can finish dining within $k$ units of time. (NO space and '\n' at the end)

Sample Input  Download

Sample Output  Download

Tags




Discuss