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