def a_candy_distribution_again(N, X, A):
    A.sort()
    ans = 0
    for a in A:
        if a <= X:
            ans += 1
            X -= a
    if X > 0 and ans > 0:
        ans -= 1
    return ans

N, X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(a_candy_distribution_again(N, X, A))