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

count = 0
for i in sorted(a):
    if x >= i:
        x -= i
        count += 1
    else:
        break    
if x == 0:
    print(count)
else:
    print(count - 1)
