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