function Main(input) {
	var str = input;
	var ans = 0;
	var str = str.split("\n")[0];
	var num = str.split(" ");
	var n = Number(num[0]);	
	var a = Number(num[1]);	
	var b = Number(num[2]);
	
	var sa = a-1;
	var bn = n-b;
	var ab = b-a;
	if(ab ===0){
		ans  = 0;
	}else if (ab%2 !==0){
		if(sa<=bn){
			ans = sa+ab;
		}else{
			ans = ab+bn;
			}
	}else{
		ab = ab/2;
		if (ab<=sa&& ab<=bn){
			ans = ab;
		}else if(sa<=bn){
			ans = sa+ab;
		}else{
			ans = ab+bn;
			}
	}
	console.log(ans);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));