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