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