n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
a.sort(reverse=True,key=int)
ansr=0
for i in range(n-1):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ansr+=1
print(max(ans,ansr))
