N, x = list(map(int, input().split()))
ais = list(map(int, input().split()))
s = 0
cnt = 0
ais.sort()
for ai in ais:
    if(s+ai>=x):
        break
    else:
        s += ai
        cnt += 1
print(cnt)