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