Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/ochkoz-eng-kop-xarid

Maximum purchases

Easy 1000 ms 128 MB 22%
Share

A shop has $n$ different items, the price of the $i$-th item is $p_{i}$ soums; each item can be bought at most once. The customer has $B$ soums. What is the largest number of items they can buy?

Prices in cells; the items chosen starting from the cheapest that fit into the budget

Input

The first line contains two integers: $n$ and $B$. The second line contains $n$ space-separated positive integers $p_{i}$.

Output

One integer — the largest number of items that can be bought.

Note

$1 \le n \le 10^{5}$
$1 \le p_{i} \le 10^{9}$
$0 \le B \le 10^{14}$

Examples

Input #1
5 20
8 3 12 5 7
Output #1
3
Input #2
3 2
5 3 4
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.