import java.math.*; import java.util.*; public class Main { class pair{ int num; int cost; pair(int num,int cost){ this.num=num; this.cost=cost; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int v = sc.nextInt(); int sx = sc.nextInt()-1; int sy=sc.nextInt()-1; int gx=sc.nextInt()-1; int gy=sc.nextInt()-1; int[][] map = new int[n][n]; for(int i=0;i queuex = new LinkedList(); Queue queuey = new LinkedList(); Queue hosuu = new LinkedList(); totalcost[sy][sx]=0; queuex.offer(sx); queuey.offer(sy); hosuu.offer(0); while(!queuex.isEmpty()){ int nx = queuex.poll(); int ny = queuey.poll(); int nh = hosuu.poll(); if(nx==gx && ny == gy){ System.out.println(nh); return; } for(int i=0;i<4;i++){ if(nx+dx[i]>=0 && nx+dx[i]=0 && ny+dy[i]