N, K = map(int, input().split()) A = [int(input()) for _ in range(N)] ans = 0 for BIT in range(1, 1 << N): RESULT = 0 for J in range(N): if (BIT >> J) & 1: RESULT += A[J] if RESULT <= K: ans = max(ans, RESULT) print(ans)