#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	long long n = x / d, r = x % d;
	if (n > k) cout << (x - k * d);
	else if ((k - n) % 2) cout << abs(d - r);
	else cout << r;
	return 0;
}