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