#include<stdio.h>
int main(void)
{
	long long a,b,c,d,e,f,g;
	scanf("%lld %lld %lld",&a,&b,&c);
	if(a<0) a=-a;
	d=a/c;
	e=a%c;
	if(d<=b){
		f=d-b;
		if(f%2==0){
			printf("%lld\n",e);
		}
		else {
			printf("%lld\n",c-e);
		}
	}
	else {
		printf("%lld\n",a-(b*c));
	}
	return 0;
}
