n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
i = 0
while x >= 0 and n-2 >= i:
    x = x - a[i]
    if x >= 0:
        i += 1
    else:
        break
if x <= 0:
    print(i)
else:
    if x == a[-1]:
        x += 1
        print(x)
    else:
        print(x)
    