n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
cnt = 0
for i in range(n):
    if a[i]<=x:
        x-=a[i]
        cnt += 1
if x!=0:
    cnt -= 1
print(min(0,cnt))