# Problem A - Candy Distribution Again

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

# initialization
a_list = sorted(a_list)
person_num = 0

# count process
for i in range(len(a_list)):
    a = a_list[i]
    if x>=a:
        person_num += 1
        x = x - a
    else:
        break

# output
print(person_num)
