length, prog_ps = map(int, input().rstrip().split(' ')) yu_time = length // (prog_ps * 2) if (length % (prog_ps * 2) == 0) and (yu_time > 0): yu_time -= 1 print(prog_ps * yu_time)