#include"bits/stdc++.h"
using namespace std;
#define int long long
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
int power(int n, int k) {
    if (k == 0) {
        return 1;
    }
    int curr = power(n, k / 2);
    if (k % 2 == 0) {
        return ((curr % mod * curr % mod) % mod);
    }
    else {
        return ((n % mod * curr % mod * curr % mod) % mod);
    }
}
int min(int a, int b) {
    if (a < b)
        return a;
    else
        return b;
}
bool compare(int a, int b) {
    return a > b;
}

int32_t main() {
    fio;
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    }
    else if (b == c) {
        cout << a << endl;
    }
    else if (a == c) {
        cout << b << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define f1 first
#define f2 second
#define ll long long
#define pii pair<int,int>
#define fastio() cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)          //no scanf
#define fileio(code) freopen("code.in","r",stdin);freopen("code.out","w",stdout)  //file name
using namespace std;

ll t,x,y,z,n;

bool ff(int a,int b,int c,int d){
	if((a-b==c-d) || (a+b==c+d) || (abs(a-c)+abs(b-d)<4)) return true;
	return false;
}


char ch;
int32_t main(){
	fastio();
	//fileio(code);
	cin>>x>>y>>z>>t;

	if(x==z && y==t) cout<<"0";
	else if(ff(x,y,z,t)) cout<<"1";
	else if(ff(x-3,y,z,t)) cout<<"2";
	else if(ff(x-2,y-1,z,t)) cout<<"2";
	else if(ff(x-2,y,z,t)) cout<<"2";
	else if(ff(x-2,y+1,z,t)) cout<<"2";
	else if(ff(x-1,y-2,z,t)) cout<<"2";
	else if(ff(x-1,y-1,z,t)) cout<<"2";
	else if(ff(x-1,y,z,t)) cout<<"2";
	else if(ff(x-1,y+1,z,t)) cout<<"2";
	else if(ff(x-1,y+2,z,t)) cout<<"2";
	else if(ff(x,y-3,z,t)) cout<<"2";
	else if(ff(x,y-2,z,t)) cout<<"2";
	else if(ff(x,y-1,z,t)) cout<<"2";
	else if(ff(x,y+1,z,t)) cout<<"2";
	else if(ff(x,y+2,z,t)) cout<<"2";
	else if(ff(x,y+3,z,t)) cout<<"2";
	else if(ff(x+1,y-2,z,t)) cout<<"2";
	else if(ff(x+1,y-1,z,t)) cout<<"2";
	else if(ff(x+1,y,z,t)) cout<<"2";
	else if(ff(x+1,y+1,z,t)) cout<<"2";
	else if(ff(x+1,y+2,z,t)) cout<<"2";
	else if(ff(x+2,y-1,z,t)) cout<<"2";
	else if(ff(x+2,y,z,t)) cout<<"2";
	else if(ff(x+2,y+1,z,t)) cout<<"2";
	else if(ff(x+3,y,z,t)) cout<<"2";
	else if((abs(x-z)+abs(y-t))%2==0) cout<<"2";
	else cout<<"3";
	return 0;
}