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

num_lists.sort()
cnt = 0
for i in num_lists:
    if i <= x:
        cnt += 1
        x -= i
    else:
        break

if num_lists[0] <= x:
    cnt -= 1

print(cnt)