N, M = map(int, input().split()) C = list(map(int, input().split())) ans = 0 C.sort() for i in range(N): if M < C[i]: break M -= C[i] ans += 1 print(ans)