#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using Int = long long;

int main(){
    vector<int>v(4);
    for(auto& e : v) cin >> e;
    int ans = 1e9;
    sort(v.begin(),v.end());
    do{
        ans = min(ans,abs((v[0] + v[1]) - (v[2] + v[3])));
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}

