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


if sum(A) < x:
    x -= sum(A)
    A.sort()
    ans = n
    
    for a in A:
        if x - a >= 0:
            x -= a
            ans -= 1
        # else:
        #     break

else:
    A.sort(reverse=True)
    ans = 0
    for a in A:
        if x - a >= 0:
            x -= a
            ans += 1
        # else:
        #     break


print(ans)