n,x = map(int,input().split())

a = list(map(int,input().split()))

a.sort()


now=x
cnt=0
for i in range(n):
    now -=a[i]
    cnt +=1
    if now<0:
        cnt -=1
        break

if now==0:
    print(cnt)
else:
    print(cnt-1)
