#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
int main(){
  ll i,j,r[2],c[2],res=0;
  for(i=0;i<2;i++){
    cin >> r[i] >> c[i];
  }
  if(r[0]==r[1] && c[0]==c[1]){
    res = 0;
  }else if(r[0]+c[0]==r[1]+c[1] || r[0]-c[0]==r[1]-c[1] || abs(r[0]-r[1])+abs(c[0]-c[1])<=3){
    res = 1;
  }else if(abs(r[0]-r[1])+abs(c[0]-c[1])<=6 || zt(r[0]+c[0],r[1]+c[1])<=3 || zt(r[0]-c[0],r[1]-c[1])<=3){
    res = 2;
  }else if((r[0]+c[0])%2==(r[1]+c[1])%2){
    res = 2;
  }else{
    res = 3;
  }
  cout << res << endl;
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,a,b;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    if(n==a&&m==b){
        printf("0\n");
    }
    else if(n+m==a+b||n-m==a-b||abs(n-a)+abs(m-b)<=3){
        printf("1\n");
    }
    else{
        if((abs(n+m)+abs(a+b))%2==0){
            printf("2\n");
        }
        else {
            for(int i=n-3;i<=n+3;i++){
                for(int j=m-3;j<=m+3;j++){
                    if(abs(i-n)+abs(j-m)>3)continue;
                    else if(i+j==a+b||i-j==a-b||abs(i-a)+abs(j-b)<=3){
                        printf("2\n");
                        return 0;
                    }
                }
            }
            printf("3\n");
        }
    }
    return 0;
}