l,k=map(int,input().split()) print(k*(l//(2*k)-[0,1][l%(2*k)==0]))