function Main(input) {
    input = input.split(" ").map(x => parseInt(x));
    if((input[2]-input[1])%2==0){
        ans = Math.abs((input[2]-input[1])/2);
    }
    else{
        ans = (Math.floor((input[2]-input[1])/2))+1+(Math.min(input[1]-1,input[0]-input[2]))
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));