import math
import os
import random
import re
import sys
def maximumToys(prices, k):
    prices.sort()
    counter = 0
    index = 0
    while k > prices[index]:
        k -= prices[index]
        counter += 1
        index += 1
    return (counter)
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    nk = raw_input().split()

    n = int(nk[0])

    k = int(nk[1])

    prices = map(int, raw_input().rstrip().split())

    result = maximumToys(prices, k)

    fptr.write(str(result) + '\n')

    fptr.close()
