n, x = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
for i in range(0, n):
    x = x-b[i]
    if x == 0:
        print(i+1)
        break
    elif x<0:
        print(i)
        break
    else:
        continue