import strutils, sequtils, math var A = newSeq[int]() best = 0 let NK = stdin.readLine.split.map parseInt (N, K) = (NK[0], NK[1]) for i in 0 ..< N: A.add stdin.readLine.parseInt for i in 0 ..< (2 ^ N): var cnt = 0 for j, c in i.toBin(N): if c == '1': cnt += A[j] if cnt <= K: best = max(cnt, best) else: break echo best