a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = sorted(b)

for i in range(a[0]):
  if i == 0 and a[1] < b[0]:
    print(0)
    break
  a[1] -= c[i]
  if a[1] <= 0:
    print(i+1)
    break
else:
  if a[1] == 0:
    print(a[0])
  else:
    print(a[0]-1)