N, K = map(int, input().split()) A = [int(input()) for i in range(N)] from itertools import product ans = 0 for i in product(range(2), repeat=N): x = sum([A[j] * i[j] for j in range(N)]) if x <= K: ans = max(ans, x) print(ans)