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

c_list = list(map(int, input().split()))

c_list.sort()


i = 0
for _ in range(len(c_list)):
    if x - c_list[i] < 0:
        print(i)
        exit()
    x -= c_list[i]
    i += 1

print(len(c_list))
