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

sorted_a = sorted(a)
cont = 0

for i in range(N):
    if x >= sorted_a[i]:
        cont += 1
        x = x - sorted_a[i]
if x != 0:
    cont = cont -1
print(cont)