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

int main(){
    ll X,K,D;
    cin>>X>>K>>D;
    X=abs(X);
    ll Z=X/D;
    if(K<Z)cout<<X-K*D;
    else{
        if ((Z-K)%2==0) cout<<abs(X-Z*D);
        else cout<<abs(X-(Z+1)*D);
    }
}
