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