n, m=map(int, input().split()) c=sorted(list(map(int, input().split()))) count = 0 for a in c: m-=a if m>=0: count += 1 if m<=0: break print(count)