#agc027a
import sys

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