#coding=UTF-8 mojir=input() hyo=mojir.split(' ') N=int(hyo[0]) M=int(hyo[1]) mojir=input() hyo=mojir.split(' ') C=[int(mono) for mono in hyo] kireiC=sorted(C) tmpkei=0 #一気に取る感じでOK ans=0 for idx in range(0,N,1): if kireiC[idx]+tmpkei > M: break elif kireiC[idx]+tmpkei == M: ans=ans+1 break else: tmpkei=tmpkei+kireiC[idx] ans=ans+1 print(ans)