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

a.sort()

for i in range(n) :
   b += a[i]
   if b > x :
      break
else :
   if b == x :
      print(n)
   else :
      print(n-1)