p_c,k_c=(int(x) for x in input().split())
al=list(map(int,input().split()))
al.sort(reverse=True)
count=0
for i in range(p_c):  
  if i==al.index(al[-1]):
    k_c=k_c-al[i]
    if k_c==0:
      count+=1
    else:
      break
  elif k_c==0 or k_c<0:
    break
  else:
    k_c=k_c-al[i]
    count+=1
print(count)

