N, M = map(int, input().split()) C = sorted(map(int, input().split())) for i in range(N): S = sum(C[:i]) if M <= S: break print(i)