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