function Main(input) {
  var input = input.split('\n');

  var ret = 0;
  for (var i = 0; i < input[0]; i++) {
    var aDistance = input[2];
    var bDistance = input[1] - input[2];
    var ret = ret + (aDistance < bDistance ? aDistance : bDistance) * 2;
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));