L,K = map(int,input().split()) eat_count = L // (2 * K) if eat_count != 1: print(eat_count * K) else: print(eat_count - 1)