//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
//#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <random>
#include <cassert>
#include <cstring>
#include <sstream>
#include <complex>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;


//int input........
template <typename T> inline void readline(T &n) {n = 0; int f = 1; register int ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}


// long long input........
template <typename T> inline void readlinel(T &n) {n = 0; long long f = 1; register long long ch = getchar();
 for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;for (; isdigit(ch); 
ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readlinel(T &n, TT &m) { readlinel(n); readlinel(m); }
template <typename T, typename TT, typename TTT> inline void readlinel(T &n, TT &m, TTT &l) { readlinel(n, m); readlinel(l);}


//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}


//............ignore it..................//
#define F first
#define S second
#define Pi atan(1)*4
#define mp make_pair
#define pb  push_back
const int M	= 1e9 + 7;
#define ll  long long int
#define happy cin.tie(0);
#define point(x) setprecision(x)
void Print(int n){printf("%d ", n);}
void print(int n){printf("%d\n", n);}
#define Test printf("Case %d: ",tc++);
int length(string s){return s.size();}
void print(ll n){printf("%I64d\n", n);}
void Print(ll n){printf("%I64d ", n);}
#define coding ios::sync_with_stdio(false);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
void print(int n,int m){printf("%d ",n);printf("%d ",m);}
void print(ll n,ll m){printf("%I64d ",n);printf("%I64d ",m);}
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;
int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;}
int dx[8]= {1,0,-1,0,-1,-1,1,1};int dy[8]= {0,1,0,-1,-1,1,-1,1}; int tc = 1;
void print(int n,int m,int k){printf("%d ",n);printf("%d ",m);printf("%d ",k);}
void print(ll n,ll m,ll k){printf("%I64d ",n);printf("%I64d ",m);printf("%I64d ",k);}
long long pow(long long a,long long n){ll res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;}


template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }


#define   pr 	pair<int, int> 
#define   vpr 	vector<pr> 
#define   vi   	std::vector<int>
#define   vll  	std::vector<ll>
#define   all(n) n.begin(),n.end()


const int Inf           = (int)2e9 + 5;
const ll  Lnf           = (ll)2e18 + 5;
const int N             = 5e3 + 5;
const int NN            = 1e6 + 5;


int solve() 
{
	//happy coding

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,min(b,min(c,d)))<<endl;
	



	return 0;
	//error();
}
int main(){
	int test = 1;
	//readline(test);//(void)getchar();
	while (test--)solve();return 0;
}
// Username: WillTheBill
// Time of creation: 2020-11-22 12:49
// Original filename: m.cp.cpp

#include<bits/stdc++.h>
using namespace std;

// shortcuts
#define pb push_back
#define fi first
#define se second
#define all(_v) _v.begin(),_v.end()
#define ll long long

// IO
#define multitest signed __T; cin >> __T; while(__T--)
template<typename T>
void _read(T& t);
template<typename T>
void _read(vector<T>&v);
template<typename T1, typename T2>
void _read(pair<T1,T2>&p);
template<typename T>
void _read(T& t){cin >> t;}
template<typename T>
void _read(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_read(v[_i]);}
template<typename T1, typename T2>
void _read(pair<T1,T2>&p){_read(p.first);_read(p.second);}
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){_read(t);_masterread(v...);}
#define re(...)_masterread(__VA_ARGS__)

template<typename T>
void _print(T t);
template<typename T>
void _print(vector<T>&v);
template<typename T1, typename T2>
void _print(pair<T1,T2>&p);
template<typename T>
void _print(T t){cout<<t;}
template<typename T>
void _print(vector<T>&v){for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cout<<(_i==v.size()-1?"":" ");}
template<typename T1, typename T2>
void _print(pair<T1,T2>&p){_print(p.first);cout<<" ";_print(p.second);}
void _masterprint(){cout<<endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){_print(t);if(sizeof...(v))cout<<" ";_masterprint(v...);}
#define pr(...)_masterprint(__VA_ARGS__)

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _debug(T t);
template<typename T1,typename T2>
void _debug(pair<T1,T2> p);
template<typename T>
void _debug(vector<T>v);
template <typename T> // end forward declaration
void _debug(T t){cerr<<t;}
template<typename T1,typename T2>
void _debug(pair<T1,T2> p){cerr<<"{";_debug(p.first);cerr<<", ";_debug(p.second);cerr<<"}";}
template<typename T>
void _debug(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_debug(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_debug(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...) 
#endif

// TYPES
#define int long long

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a,b,c,d; re(a,b,c,d);
	int res = 3;
	if(a==c&&b==d) res = 0;
	if(a + b == c + d) res = min(res, 1ll);
	if(a - b == c - d) res = min(res, 1ll);
	if(abs(a-c) + abs(b - d) <= 3) res = min(res, 1ll);
	for(int i = a - 10; i <= a + 10; i++){
		for(int j = b - 10; j <= b + 10; j++){
			if(!(i + j == a + b || i - j == a - b || abs(i - a) + abs(j - b) <= 3)) continue;
			if(i == c && j == d) res = min(res, 1ll);
			if(i + j == c + d) res = min(res, 2ll);
			if(i - j == c - d) res = min(res, 2ll);
			if(abs(i - c) + abs(j - d) <= 3) res = min(res, 2ll);
		}
	}
	if((a + b) % 2 == (c + d) % 2){
		res = min(res, 2ll);
	}
	/*int l = -1e10, r = 1e10;
	while(l <= r){
		int m = (l + r) / 2;
		int d1 = abs(a + m - c) + abs(b + m - d);
		if(d1 == 0){
			res = min(res, 1ll);
		}
		if(d1 <= 3){
			res = min(res, 2ll);
			break;
		}
		int d2 = abs(a + m + 1 - c) + abs(b + m + 1 - d);
		if(d2 < d1){
			l = m + 1;
		}else{
			r = m - 1;
		}
	}
	l = -1e10, r = 1e10;
	while(l <= r){
		int m = (l + r) / 2;
		int d1 = abs(a + m - c) + abs(b - m - d);
		if(d1 == 0){
			res = min(res, 1ll);
		}
		if(d1 <= 3){
			res = min(res, 2ll);
			break;
		}
		int d2 = abs(a + m + 1 - c) + abs(b - (m + 1) - d);
		if(d2 < d1){
			l = m + 1;
		}else{
			r = m - 1;
		}
	}*/
	pr(res);
}
