n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

cnt = 0
for i in range(n):
    if i==n-1:
        if x-a[i]!=0:
            pass
        else:
            cnt+=1
    elif x-a[i]>=0:
        x -= a[i]
        cnt += 1
    else:
        pass
print(cnt)