N, x = map(int, input().split())
a = sorted(map(int, input().split()))
ans = 0
frag = False
for i in range(N):
    
    if x-a[i] >= 0:
        frag = True
        x -= a[i]
        ans += 1
    else:
        break
if frag == True:
    if x >= 1:
        print(ans-1)
    elif x == 0:
        print(ans)
else:
    print(0)