l,k = map(int,input().split()) tmp = l//(k*2) if l%(k*2) == 0: print(max((tmp-1)*k,0)) else: print(tmp*k)