Amit and Cookies

0

0 votes
Problem

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.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

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

Editor Image

?