import numpy as np
tmp1 = list(map(int, input().split()))
N = tmp1[0]
x = tmp1[1]
a = np.array(list(map(int, input().split())))
a = np.sort(a)
count = 0
for i in range(N):
  x -= a[i]
  if x == 0:
    count += 1
    break
  elif x < 0:
    if count != 0:
    	count -= 1
    break
  else:
    count += 1
print(count)

