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

for i in a:
    x -= i
    if x >= 0:
        ans += 1
    else:
        break
if x != 0 and ans != 0:
    ans -= 1

print(ans)