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

a = sorted(a)

count = 0

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