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:
    cnt += 1
    if x - i < 0:
        break
    else:
        x -= i

print(cnt)
