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