All Tracks Problem

Amit and Cookies
/
No tags
Problem
Editorial
Analytics

Amit is very fond of cookies, so he wants to buy some. There are N different cookies lying in front of him, with their prices, but he has only K Rs. He wants to maximize the number of cookies he buys with this money.

Now, you are Amit's best friend and have to help him buy as many cookies as possible.

Input Format

The first line contains two integers, N and K, followed by a line containing N space separated integers indicating the cookies' prices.

Output Format

An integer that denotes maximum number of cookies Amit can buy.

Constraints

1<=N<=10^5

1<=K<=10^9

1<=price of any cookie<=10^9

There is only one cookie of each type.

SAMPLE INPUT
5 50
12 81 23 5 29
SAMPLE OUTPUT
3
Explanation

He can buy only 3 cookies at most. These cookies have the following prices: 12,23,5.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?