n,x = map(int,input().split())
a = list(map(int,input().split()))

Slist = sorted(a)
cnt = 0
Sum = 0

for i in range(len(Slist)):
  Sum += Slist[i]
  if x>=Sum:
    cnt +=1
  else:
    break
print(cnt)