import 'dart:io';

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

  int x = (xkd[0]).abs();
  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 b = x % d;
    var a = ((x - b) / d);
    if ((k % 2 == a % 2)) {
      int p = 2 * d - b;

      if (p < b) {
        ans = p;
      } else {
        ans = b;
      }
    } else {
      if ((d + b) <= (d - b).abs()) {
        ans = b + d;
      } else {
        ans = (d - b).abs();
      }
    }
  }

  print(ans);
}