N,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if min(a) > x:
    print(0)
    exit()
for i in range(N):
    x -= a[i]
    if x <= 0:
        print(i+1)
        exit()
print(N-1)