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