from itertools import combinations n, k = map(int, input().split()) a = [int(input()) for _ in range(n)] maximum = 0 for num in range(1, n+1): for combi in combinations(a, num): canditate = sum(combi) if canditate <= k and maximum < canditate: maximum = canditate print(maximum)