f=lambda:map(int,input().split()) n,m=f() *c,=f() c.sort() for i in range(n): c[i],m=c[i]-min(m,c[i]),m-c[i] if m<=0: print(c.count(0)) break