#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c;
	cin>>a>>b>>c;
	a=abs(a);
if(a>0&&a/c>=b)
cout<<a-b*c<<endl;
else
{
long long int f=a/c;
a-=f*c;
b-=f;
if(b%2==0)
cout<<abs(a)<<endl;
else
cout<<min(abs(a+c),abs(a-c))<<endl;;
}
	return 0;
}
