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

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