length, each_event_size = map(int, input().split()) cnt, mod = divmod(length, (each_event_size * 2)) print(each_event_size * cnt) if mod != 0 else print(each_event_size * (cnt - 1))