N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    elif i == children[N - 1] and x - i > 0:
        print(N - 1)
    else:
        x -= i
        cnt += 1

print(cnt)
