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

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