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