def solver(N, x, requests):
    count = 0
    list.sort(requests)
    for req in requests:
        if x < req:
            break
        x -= req
        count += 1
    if count > 0 and x > 0:
        count -= 1
    return count
N, x = tuple([int(n) for n in input().split(" ")])
requests = [int(n) for n in input().split(" ")]
print(solver(N, x, requests))