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