import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int min = -1; static boolean[][] visited; static int[][] visited_moves; public static void solve(int b, int e, int x, int y, int moves, int n) { if(b > n-1 || e > n-1 || b < 0 || e < 0) return; if(moves >= min && min != -1) return; if(b == n-1 && e == n-1) { if(moves < min || min == -1) { min = moves; return; } } if(visited[b][e] && moves >= visited_moves[b][e]) return; visited[b][e] = true; visited_moves[b][e] = moves; solve(b+x,e+y,x,y,moves+1,n); solve(b+x,e-y,x,y,moves+1,n); solve(b-x,e+y,x,y,moves+1,n); solve(b-x,e-y,x,y,moves+1,n); solve(b+y,e+x,x,y,moves+1,n); solve(b+y,e-x,x,y,moves+1,n); solve(b-y,e+x,x,y,moves+1,n); solve(b-y,e-x,x,y,moves+1,n); //visited[b][e] = false; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); visited = new boolean[n][n]; visited_moves = new int[n][n]; int[][] sol = new int[n][n]; for(int i=1 ; i