class Problem0063: def solve(this): l,k = map(int, input().split()) res = l // (k * 2) cnt = 0 if l % (k * 2) == 0: cnt = res - 1 else: cnt = res print(cnt * k) if __name__ == "__main__": problem = Problem0063() problem.solve()