import 'dart:io';

void main() {
  List xkd = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();

  int x = (xkd[0] < 0) ? -xkd[0] : xkd[0];
  int k = xkd[1];
  int d = xkd[2];

  int ans;
  if (x == 0) {
    ans = (k % 2 == 0) ? 0 : d;
  } else if (x > k * d) {
    ans = x - (k * d);
  } else {
    int a = (x / d).floor();
    int b = x % d;

    ans = ((k - a) % 2 == 0) ? b : d - b;
  }
  print(ans);
}
