n,x=int(input().split())
N=list(map(int,input().split()))
K=sorted(N,reverse=True)
if sum(K)<=x:
  print(n)
  sys.exit()
for i in range(1,n+1):
  if sum(K)-K[0]<=x:
    print(n-i)
    sys.exit()
  else:
    K.pop(0)