#K60912. Max Invitees

    ID: 31192 Type: Default 1000ms 256MiB

Max Invitees

Max Invitees

You are given a number of colleagues N and a budget B. Each colleague has an associated cost. Your task is to determine the maximum number of colleagues Lena can invite such that the total cost does not exceed the budget.

More formally, given a list of costs \(c_1, c_2, \ldots, c_N\), find the largest integer \(k\) such that there exists a subset of \(k\) elements with \(\sum_{i=1}^{k} c_{i}\le B\). It is always optimal to choose the colleagues with the smallest costs first.

inputFormat

The first line contains two space-separated integers \(N\) and \(B\), where \(N\) (\(1 \leq N \leq 10^5\)) is the number of colleagues and \(B\) (\(1 \leq B \leq 10^9\)) is the available budget.

The second line contains \(N\) space-separated integers representing the cost for each colleague.

outputFormat

Output a single integer representing the maximum number of colleagues that can be invited without exceeding the budget.

## sample
5 50
10 20 30 40 50
2