_,m=map(int,input().split()) for i,j in enumerate(sorted(map(int,input().split()))): m-=j if m==0: i+=1 break elif m<0:break print(i)