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

a.sort()

if x<a[0]:
    print(0)
    exit()

for i in range(N):
    x = x - a[i]
    if x <=0:
        print(i+1)
        exit()
print(N-1)
    