l, k = map(int, input().split()) q = l // (2 * k) if l % (2 * k) == 0: q -= 1 print(q * k)