N, M = map(int, input().split()) L = sorted(list(map(int, input().split()))) n = 0 c = 0 while L[n] <= M: M -= L[n] c += 1 n += 1 if n == N: c = N break print(c)