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

count = 0
for child in children:
    if x >= child:
        x -= child
        count += 1
    else:
        break
if x == 0:
    print(count)
else:
    if count != 0:
        print(count - 1)
    else:
        print(0)