L,K=map(int,input().split()) if L/2<=K: print(0) else: x=int(L/2//K*K) if L/2%K == 0: x-=K print(x)