L, K = [int(i) for i in input().split()] print((L // (K * 2)) * K if L % (K * 2) != 0 else ((L // (K * 2)) - 1) * K)