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

typedef long long int in;

int main()
{
    in a,b,c,d;
    cin>>a>>b>>c>>d;

    cout<<min({a,b,c,d});

    return 0;
}
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using C = complex<double>;

int solve() {
    ll r1, c1, r2, c2;
    cin >> r1 >> c1;
    cin >> r2 >> c2;
    if (r1 == r2 && c1 == c2) return 0;
    if (r1 + c1 == r2 + c2) return 1;
    if (r1 - c1 == r2 - c2) return 1;
    if (abs(r1-r2) + abs(c1-c2) <= 3) return 1;
    if ((r1+c1) % 2 == (r2+c2) % 2) return 2;
    if (abs(r1-r2) + abs(c1-c2) <= 6) return 2;
    if (abs((r1+c1)-(r2+c2)) <= 3 || abs((r1-c1)-(r2-c2)) <= 3) return 2;
    return 3;
}


int main() {
   cout << solve() << endl;
}