N, x = map(int, input().split())
an = list(map(int, input().split()))
an.sort()
flag = [0]*N
count = 0
i = 0
while(1):
  if x >= an[i]:
    x -= an[i]
    if flag[i] == 0:
      flag[i] += 1
      count += 1
    else:
      count -= 1
  else:
    i = 0
  if x == 0:
    break
  i += 1
  if i >= N:
    i = 0
print(count)