import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.omg.PortableInterceptor.INACTIVE;
public class Grasshop {
public static int maxX;
public static int maxY;
public static void rekurze(int[][] pole, int x, int y, int hodnota) {
if (hodnota >= 5) return;
if (x<0) return;
if (x>=maxX) return;
if (y<0) return;
if (y>=maxY) return;
else {
if ((pole[x][y] > hodnota) || (pole[x][y] == 0)) {
pole[x][y] = hodnota;
rekurze(pole, x+2, y+1, hodnota+1);
rekurze(pole, x-2, y+1, hodnota+1);
rekurze(pole, x+2, y-1, hodnota+1);
rekurze(pole, x-2, y-1, hodnota+1);
rekurze(pole, x+1, y+2, hodnota+1);
rekurze(pole, x-1, y+2, hodnota+1);
rekurze(pole, x+1, y-2, hodnota+1);
rekurze(pole, x-1, y-2, hodnota+1);
}
}
}
public static void main
(String[] args
) { while (true) {
try {
linka = bfr.readLine();
if (linka == null) break;
String ln
[] = linka.
split(" ");
int sX
= Integer.
parseInt(ln
[2])-1; int sY
= Integer.
parseInt(ln
[3])-1; int cX
= Integer.
parseInt(ln
[4])-1; int cY
= Integer.
parseInt(ln
[5])-1;
if ((sX == cX) && (sY == cY)) {
continue;
}
if ((maxX < 2) || (maxY < 2)) {
System.
out.
println("impossible"); continue;
}
int[][] pole = new int[maxX][maxY];
rekurze(pole, cX, cY, 0);
pole[cX][cY] = 9;
//pole[sX][sY] = 7;
/*
for(int i=0; i<maxY; i++) {
for(int j=0; j<maxX; j++) {
System.out.print(pole[j][i]);
}
System.out.println();
}
*/
int pocetSkoku = 0;
while (pole[sX][sY] == 0) {
pocetSkoku++;
pole[sX][sY] = 8;
int rozX = cX-sX;
int rozY = cY-sY;
if (Math.
abs(rozX
) + Math.
abs(rozY
) < 2) { break;
}
int skX, skY;
if (rozX > 0) skX = 2;
else skX = -2;
if (rozY == 0) {
if ((sY-1) < 0) skY = 1;
else skY = -1;
} else {
if (rozY > 0) skY = 1;
else skY = -1;
}
sX += skX;
sY += skY;
} else {
int skX, skY;
if (rozY > 0) skY = 2;
else skY = -2;
if (rozX == 0) {
if ((sX-1) < 0) skX = 1;
else skX = -1;
} else {
if (rozX > 0) skX = 1;
else skX = -1;
}
sX += skX;
sY += skY;
}
}
if (pocetSkoku
== Integer.
MAX_VALUE) { System.
out.
println("impossible"); } else {
pocetSkoku += pole[sX][sY];
System.
out.
println(pocetSkoku
); }
/*
for(int i=0; i<maxY; i++) {
for(int j=0; j<maxX; j++) {
System.out.print(pole[j][i]);
}
System.out.println();
}
*/
}
}
}
}