#agc027a
import sys

n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
res=x
for i in xrange(n):
 res-=a[i]
 if res<=0:
  if a[0]>x:
   print 0
  else:
   print i+1
  sys.exit()
print n-1
