#coding: UTF-8 import sys from math import pi from collections import deque from functools import reduce ### defs ### ### main ### L,K = map(int,sys.stdin.readline().split()) print((L//(2*K)-1)*K if L%(2*K)==0 else L//(2*K)*K)