const standardInput = process.stdin;
standardInput.setEncoding('utf-8');

function tableTennis([N, A, B]) {
    // Even amount of tables in between
  if ((B - A) % 2 == 0) {
    return ((B - A) / 2);
  }
  
  // Uneven amount of tables in between
  if (A - 1 < N - B) {
    return A + tableTennis([N, 1, B - A])
  } else {
    const stepsToEven = N - B + 1;
    return stepsToEven + tableTennis([N, A + stepsToEven, N])
  }
}

standardInput.on('data', function (data) {
    data = data.split(" ");
    data[0] = parseInt(data[0]);
    data[1] = parseInt(data[1]);
    data[2] = parseInt(data[2].replace("\n", ""));
    console.log(tableTennis(data))
});
