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', (data) => {
    test = data.split(" ");
    test[0] = parseInt(test[0]);
    test[1] = parseInt(test[1]);
    test[2] = parseInt(test[2].replace("\n", ""))
    console.log(tableTennis(test));
    process.exit();
});
