L, K = map(int, input().split()) b = L % (K*2) a = L // (K*2) if b == 0: a -= 1 ANS = a * K print(ANS)