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