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

a.sort()

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