N, x = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array, reverse=False)
if sum(array) <= x:
  print(N)
elif array[0] > x:
  print(0)
for i in range (N):
  if sum(array[0:i]) >= x:
    print(i)
    break