#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 10, M = 1000010;
typedef pair<int, int> PII;
int dx[] = {0, 1, 2, 2, 1, -1, -2, -2, -1};
int dy[] = {0, 2, 1, -1, -2, -2, -1, 1, 2};
int step[N][N];
bool map[N][N];
PII q[M];
int main(){
int xx, yy, aa, bb;
cin >> xx >> yy >> aa >> bb;
step[xx][yy] = 0;
map[xx][yy] = true;
q[0] = {xx, yy};
int hh = 0, tt = 0;
while (hh <= tt){
int x = q[hh].first, y = q[hh].second;
hh ++;
for (int i = 1; i <= 8; i ++){
int a = x + dx[i], b = y + dy[i];
if (a >= 1 && a <= 8 && b >= 1 && b <= 8 && !map[a][b]){
map[a][b] = true;
q[ ++ tt] = {a, b};
step[a][b] = step[x][y] + 1;
}
}
}
cout << step[aa][bb];
return 0;
}