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

a.sort()

for i in range(n):
    x -= a[i]
    if x < 0:
        print(i)
        exit()
    elif x == 0:
        print(i+1)
        exit()
print(n)