n,m = map(int,input().split()) boxes = list(map(int,input().split())) boxes.sort() for j in range(len(boxes)): if boxes[j] != 0 and boxes[j] <= m: m -= boxes[j] boxes[j]=0 if boxes[j] != 0 and boxes[j] >= m: boxes[j] -= m m=0 print(boxes.count(0))