#K75442. Maximum Bud Blooms

    ID: 34420 Type: Default 1000ms 256MiB

Maximum Bud Blooms

Maximum Bud Blooms

You are given a tree with N buds, where each bud requires a certain amount of energy to bloom. You also have M total magic points available. Your task is to determine the maximum number of buds that can be bloomed without exceeding the available magic points.

You can choose to bloom buds in any order; however, the optimal strategy is to bloom those requiring the smallest energy first. Mathematically, if you choose k buds with energy requirements \(e_1, e_2, \ldots, e_k\) (sorted in non-decreasing order), the following inequality must hold: \[ \sum_{i=1}^{k} e_i \le M \] Determine the largest possible k that satisfies the above condition.

inputFormat

The first line contains two integers N and M, where N is the number of buds, and M is the total available magic points. The second line contains N space-separated integers representing the energy requirement for each bud.

outputFormat

Output a single integer, the maximum number of buds that can be bloomed without exceeding M magic points.

## sample
5 10
2 2 2 3 4
4