l,k=(int(i) for i in input().split()) if l%(k*2)==0: print(0) else: print(int(l/(k*2))*k)