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

a.sort()

for i in range(N):
    x -= a[i]
    if x < 0:
        print(ans)
        exit()
    else:
        ans += 1

print(N)