scan = string.gmatch(io.read(),"%d+") l = scan() - 0 k = scan() - 0 print(math.floor((l-1)/(k*2))*k)