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