import java.util.;
import java.lang.;
public class Acwing1219 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int m = sc.nextInt();
int n = sc.nextInt();
m--; n--;//便于求行号不会出现第一个边缘的余数为0
int x1 = m / w;//行
int x2 = n / w;
int y1 = m % w ;//列
int y2 = n % w ;
if((x1 & 1) == 0){//x1为奇数
y1 = w - y1 - 1;
}
if((x2 & 1) == 0){
y2 = w - y2 - 1;
}
int cout = Math.abs(y2 - y1) + Math.abs(x2 - x1);
System.out.println(cout);
}
}