N, x = map(int,input().split())

al = list(map(int,input().split()))

al.sort()

cnt = 0

for a in al:

  x -= a

  if x < 0:

    break

  cnt += 1

if x != 0 and cnt >= 1:
  print(cnt-1)
else:
  print(cnt)

  
