#include<bits/stdc++.h>
using namespace std;

long long A , B , C;
int main(){
	cin>>A>>B>>C;
	A = abs(A);
	if(A/C >= B)cout<<A - B*C<<endl;
	else{
		long long X = A/C;
		A = A - C*X;
		B = B - X;
		if(B%2==0)cout<<A<<endl;
		else cout<<abs(A-C)<<endl;
	}
}