#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,k,d,m,n,z;
	cin>>x>>k>>d;
	if(x<0)
	x=-x;
	m=x/d;
	n=x%d;
	if(m>=k)
	cout<<x-k*d;
	else
	{
		z=k-m;
		if(z%2==0)
		cout<<n;
		else
		cout<<d-n;
	}
}