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

def func():
    cummulative_sum = 0
    for index, value in enumerate(A):
        cummulative_sum += value
        if cummulative_sum > x:
            index

    if cummulative_sum != x:
        return len(A) - 1
    else:
        return len(A)

ans = func()

print(ans)