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

int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
    ll num = x/d ;
      num=min(num,k);
	  x=x-num*d;
	k=k-num;
		if(k%2==0){
			cout<<x;
		}else{
			cout<<abs(x-d);
		}		
	return 0;
}