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

ans = 0
num_list.sort()

for num in num_list:
    if x - num >= 0:
        x -= num
        ans += 1
    else:
        break

print(ans)
