N, M,*C = map(int, open(0).read().split()) C = sorted(C) X = 0 while M > 0: M -= C.pop(0) if M < 0: break X += 1 print(X)