def main(): N, K = map(int, input().split()) A = tuple(int(input()) for _ in [0] * N) weight = [] apnd = weight.append mask = 1 while mask < (1 << N): i = 0 x = 0 while i < N: if mask & (1 << i): x += A[i] i += 1 apnd(x) mask += 1 weight.sort(reverse=1) for i in weight: if i <= K: print(i) break main()