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

if x > sum(a):
  print(N-1)
elif x == sum(a):
  print(N)
else:
  for i in range(N):
    if x < sum(a[:i]):
      print(i-1)
      break