#K67357. Maximum Pizzas

    ID: 32624 Type: Default 1000ms 256MiB

Maximum Pizzas

Maximum Pizzas

You are given a list of pizza prices and a fixed budget. Your task is to determine the maximum number of pizzas that can be bought without exceeding the budget. In order to maximize the number of pizzas, you should purchase the cheaper pizzas first.

Mathematically, if we sort the prices as (p_{1} \leq p_{2} \leq \cdots \leq p_{n}), find the largest integer (k) such that (\sum_{i=1}^{k} p_{i} \leq b), where (b) is your budget.

inputFormat

The input is given via standard input (stdin) and consists of two lines. The first line contains two integers (n) and (b), where (n) (1 ≤ (n) ≤ 10^5) is the number of pizzas, and (b) (0 ≤ (b) ≤ 10^9) is the budget. The second line contains (n) space-separated integers representing the prices of the pizzas. Each price is an integer between 1 and 10^9.

outputFormat

Output a single integer on standard output (stdout) representing the maximum number of pizzas that can be bought without exceeding the given budget.## sample

5 20
4 8 6 12 10
3