#coding:utf-8 N,M=map(int,raw_input().split()) C=map(int,raw_input().split()) sorted(C) cnt=0 while 0 < M: for i in range(N): M-=C[i] cnt+=1 if M < C[i+1]: break break print cnt