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

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

standardInput.on('data', function(data) {
    test = data.split(" ");
    N = BigInt(test[0]);
    A = BigInt(test[1]);
    B = BigInt(test[2].replace("\n", ""))
    console.log(tableTennis(N, A, B));
    process.exit();
});
