N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
while len(a) != 0:
    next = min(a)
    a.remove(min(a))
    if x < next:
        break
    x -= next
    cnt += 1

cnt = 1 if cnt == 0 else cnt
print(cnt if x == 0 else cnt-1)