n,m = map(int,input().split());a=0 c = list(map(int,input().split()));c.sort() for i in range(n): if c[i]-m <= 0:a+=1;m-=c[i] print(a)