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