n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[-1]*n
for i in range(n):
  if x>=a[i]:
    b[i]=(a[i])
    x-=a[i]
  else:
    b[i]=0
cnt=0
for i,j in zip(a,b):
  if i==j:
    cnt+=1
if x==0:print(cnt)
else:
  if cnt>0:
    print(cnt-1)
  else:
    print(cnt)
    