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

a.sort(reverse=True)

cnt = 0
for i in range(len(a)):
    score = a[i]
    if i == n - 1:
        if x != score:
            break
    if x >= score:
        x -= score
        cnt += 1
print(cnt)