#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
signed main() {
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min({abs(a+b-c-d),abs(a+c-b-d),abs(a+d-b-c)})<<endl;
}
