N, x = map(int, input().split())
cage = sorted([int(i) for i in input().split()])

ans=0

for i in range(N):
    n = cage[i]
    if x>n:
        x = x - n
        ans = i
    elif x==n:
        ans = i+1
        break
    else:
        break

if cage[0]>x:
    ans=0
if x>0:
    ans = ans - 1
print(ans)