#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
long long x,k,d;
int main()
{
	cin >> x >> k >> d;
	x=abs(x);
	if(x/d >= k) 
	{
		cout << x-k*d;
		return 0;
	}
	k-=(x/d); x-=d*(x/d);
	if(k%2) x=abs(x-d);
	cout << x;
	return 0;
}