#include using namespace std; typedef pair P; const int INF = 1e9; int main() { int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; int board[y1+1][x1+1]; for(int i = 0; i < y1+1; i++) for(int j = 0; j < x1+1; j++) board[i][j] = INF; board[0][0] = 0; int dx[] = {-1,0,1,-1,1,-1,0,1},dy[] = {1,1,1,0,0,-1,-1,-1}; queue

que; que.push(P(0,0)); while(que.size()){ P xy = que.front(); if(xy.first == y1 && xy.second == x1) break; que.pop(); for(int i = 0; i < 8; i++){ int nx = xy.second + dx[i]; int ny = xy.first + dy[i]; if(nx >= 0 && nx <= x1 && ny >= 0 && ny <= y1 && board[ny][nx] == INF && !(nx == x2 && ny == y2)){ board[ny][nx] = board[xy.first][xy.second] + 1; que.push(P(ny,nx)); } } } cout << board[y1][x1] << endl; return 0; }