n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
a = sorted(a)

count = 0
for i in range(n):
    if x-a[i] >= 0:
        count += 1
        x -= a[i]
if x == 0:
    print(count)
else:
    if count == 0:
        print(0)
    else:
        print(count-1)