N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in range(N):
    if x>=a[i]:
        count += 1
        x -= a[i]
    else:
        break
print(count)