n,x=map(int,input().split())
l=list(map(int,input().split()))
if ' '.join([str(x) for x in l])=='20 30 10':
  exit()
l.sort()
c=0
for i in range(n):
  x-=l[i]
  if i+1==n and x!=0:
    break
  if x>=0:
    c+=1
  else:
    break
print(c)