n,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
count = 0
for i in range(n):
    if a_list[i] <= x:
        count += 1
        x = x-a_list[i]
    else:
        break
print(count)