n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()])
# print(A)
cnt = 0
for e in A:
    if e <= x:
        x = x - e
        cnt += 1
if x == 0 or cnt == 0:
    print(cnt)
else:
    print(cnt-1)
