#K34407. Maximizing Items Within Budget

    ID: 25302 Type: Default 1000ms 256MiB

Maximizing Items Within Budget

Maximizing Items Within Budget

You are given a total of N items with their respective prices and a total budget B. Your task is to determine the maximum number of items that can be purchased without exceeding the budget.

To achieve this, you should purchase the cheapest items first. Mathematically, if the prices are sorted in non-decreasing order as \(p_1, p_2, \ldots, p_N\), find the maximum \(k\) such that:

\(\sum_{i=1}^{k} p_i \le B\)

Print the value of \(k\).

inputFormat

The first line contains two space-separated integers \(N\) and \(B\) representing the number of items and the total budget, respectively. The second line contains \(N\) space-separated integers representing the price of each item.

outputFormat

Output a single integer denoting the maximum number of items that can be purchased without exceeding the budget.

## sample
5 50
20 30 10 40 25
2