A,B = map(int,input().split())
X =list(map(int,input().split()))
X = sorted(X)
count = 0
if B == sum(X):
  print(len(X))
elif B <= min(X):
  print(0)
else:
  for i in range(A):
    a = X.pop(0)
    B=B - a
    if B > 0:
      count += 1
  print(count-1)