import itertools N, K = map(int, input().split()) L = [int(input()) for _ in range(N)] print(L) L3 = [] for i in range(N): L2 = list(itertools.combinations(L, i)) for j in L2: if sum(j) <= K: L3 += [sum(j)] print(max(L3))