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