N, K = map(int, input().split()) A = [] for i in range(N): A.append(int(input())) ans = 0 for s in range(1 << N): v = 0 for i in range(N): if (s >> i) & 1: v += A[i] if v <= K: ans = max(ans, v) print(ans)