N, x = map(int, input().split())
a = map(int, input().split())
a_sorted = sorted(a)
sum = 0
for i in range(N):
  if sum > x:
    print(i - 1)
    break
  else:
    sum += a_sorted[i]
    if i == N-1:
      print(i -1)