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