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