def main(): N, K = map(int, input().split()) weights = [int(input()) for _ in range(N)] max_weight = 0 for bit in range(1 << N): bit_cp = bit c_weight = 0 idx = 0 while bit_cp > 0: if bit_cp & 1: c_weight += weights[idx] idx += 1 bit_cp >>= 1 if c_weight <= K and max_weight < c_weight: max_weight = c_weight print(max_weight) if __name__ == "__main__": main()