function tableTennis(N, A, B) {
  
  // one table in between
  if (B - A == 2) {
    return 1;
  } 
  
  // uneven tables in between
  if ((B - A - 1) % 2 != 0) {
    return (B - A) / 2;
  }
  
    // if A closer
    if (A - 1 <= N - B) {
       
      // more or equal than 4 tables between A and B
      if (B - A - 1 >= 4) {
        return A - 1 + (B - A - 2);
      }
      
      if (B - A - 1 == 2) {
        return A - 1  + 2;
      }
      
      return B - 1;
    }
    
    // if B closer
    if (A - 1 > N - B) {
      
      // more or equal than 4 tables between A and B
      if (B - A - 1 >= 4) {
        return N - B + (B - A - 2);
      }
      
      if (B - A - 1 == 2) {
        return N - B + 2;
      }
      
      return N - A;
    }
  
}

// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// When user input data and click enter key.
standard_input.on('data', function (data) {
  
  N = parseInt(data.split(' ')[0]);
  A = parseInt(data.split(' ')[1]);
  B = parseInt(data.split(' ')[2].replace('\n'));
  
  console.log(tableTennis(N, A, B))
  process.exit();
});