N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = 0
ans = 0
flag = True
for i in range(N):
  m += A[i]
  if m > x:
    if ans - 1 >= 0:
      print(ans-1)
    else:
      print(0)
    flag = False
    break
  elif m == x:
    print(ans+1)
    flag = False
    break
  else:
    ans += 1
if flag:
  print(ans-1)