N, K = map(int, input().split()) a = [] for i in range(N): a.append(int(input())) num = 0 for i in range(1 << N): sum = 0 for j in range(N): if ((1 << j) & i) != 0: sum += a[j] if sum > K: sum -= a[j] break num = max(sum, num) print(num)