pocky, mm = map(int, input().split()) turn = pocky // (mm*2) if pocky % mm*2 == 0: print((turn-1)*mm) else: print(turn*mm)