awk -M '\
{
    N=$1; A=$2; B=$3;
    if(A<B){
        max = B;
        min = A;
    }else{
        max = A;
        min = B;
    }
    if((max-min)%2==0){
        print (max-min)/2
    }else if(max==N){
        print N-min;
    }else if(min==1){
        print max-1;
    }else{
        ans = (N-min) > (max-1) ? (max-1) : (N-min);
        print ans
    }
}'