const input = process.argv.slice(2)

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

console.log(tableTennis(input))