
//偶數行需要反轉,判斷行數時,最后一個需要特判,可以用向上取整
//也可以把傳入的值減一,下標從0開始
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;public class Main{static int w,m,n;static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));public static void main(String[] args) throws IOException {String[] init = in.readLine().split(" ");w = Integer.parseInt(init[0]);m = Integer.parseInt(init[1]);n = Integer.parseInt(init[2]);m--;n--;int x1 = m / w; //這么寫的話 0 ~ w - 1算一層,所以上面的m和n需要先 - 1int y1 = m % w; //先這么寫,下標為0 ~ w - 1正序,通過x1判斷是否需要反轉int x2 = n / w;int y2 = n % w;if (x1 % 2 == 0) y1 = (w - 1) - y1; //此時反轉,下標為0~w-1if (x2 % 2 == 0) y2 = (w - 1) - y2; //0轉到 (w - 1) - 0 1 轉到 (w - 1) - 1//比如0轉到5,1轉到4System.out.println(Math.abs(x1 - x2) + Math.abs(y1 - y2));in.close();}
}