#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> rate(4);
    for (auto& r : rate) {
        cin >> r;
    }
    int ans = 1 << 30;
    rep(mask, 0, 1 << 4) {
        if (__builtin_popcount(mask) != 2) {
            continue;
        }
        int team1 = 0, team2 = 0;
        rep(i, 0, 4) {
            if ((mask >> i) & 1) {
                team1 += rate[i];
            }
            else {
                team2 += rate[i];
            }
        }
        chmin(ans, abs(team1 - team2));
    }
    cout << ans << endl;
    return 0;
}
