# Candy Disribution Again

N, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
num = 0
for i in range(len(a)):
    if x >= a[i] :
        num += 1
        x -= a[i]
    else :
        break
if x > 0 and num != 0 :
    num -= 1
print(num)
