n,m=map(int,input().split()) c=sorted(map(int,input().split())) x=0 for i in range(n): if sum(c[:i+1])<=m: x=x+1 print(x)