#include<cstdio>
#include<algorithm>
using namespace std;
long long a,b,c,x,y;
int main(){
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a<0)a*=-1;
    x=a/c;
    if(x>=b)printf("%lld",a-b*c);
    else{
        y=a-x*c;
        b=(b-x)&1;
        printf("%lld",abs(y-c*(b?1:0)));
    }
}
