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