N,x = map(int,input().split())
a = list(map(int,input().split()))

A = sorted(a)

n = 0

for i in A:
  x -= i
  n += 1
  if x==0:
    print(n)
    break
  elif x<0:
    print(n-1)
    break
  elif i == A[N-1]:
    print(n-1)
    break