#include <bits/stdc++.h>

using namespace std;
long long x, k, d;


int main(){
    cin>>x>>k>>d;
    if (abs(x)/d>k) cout<<abs(x)-k*d;
    else {
        long long m=k-abs(x)/d;
        if (m%2==0) cout<<abs(x)%d;
        else cout<<abs(abs(x)%d-d);
    }
}
