#include<iostream>
using namespace std;

int main(){
    int a,b,c,d,l,m,n,o,p;
    cin>>a>>b;
    cin>>c>>d;
    l=a-c;
    m=b-c;
    n=a-d;
    o=b-d;
    int max=l;

    if(m>max){
        max=m;
    }
    if(n>max){
        max=n;
    }
    if(o>max){
        max=o;
    }
    cout<<max;

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

/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define oset_find(k) find_by_order(k)
#define oset_order(k) order_of_key(k)*/

using ll = long long;
using db = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define ROF(i, a, n) for(int i=(n)-1;i>=(a);--i)

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
constexpr int pct(int x) { return __builtin_popcount(x); }

template<typename T> bool fmin(T& a, const T& b) { return b<a?a=b,1:0; }
template<typename T> bool fmax(T& a, const T& b) { return a<b?a=b,1:0; }

#define ts to_string
string ts(char c) { return '\'' + string(1, c) + '\''; }
string ts(const char* s) { return (string)s; }
string ts(const string& s) { return '"' + s + '"'; }
string ts(bool b) { return (b ? "true" : "false"); }

string ts(vector<bool> v) {
    string res = "{";
    FOR(i, 0, sz(v))
        res += char('0' + v[i]);
    res += "}";
    return res;
}

template <size_t SZ> string ts(bitset<SZ> b) {
    string res = "";
    FOR(i, 0, SZ) 
        res+=char('0'+b[i]);
    return res;
}

template <typename A, typename B> string ts(pair<A, B> p);
template <typename A> string ts(A v) {
    bool first = 1; string res = "{";
    for (const auto& x: v) {
        if (!first) res += ", ";
        first = 0; res += ts(x);
    }
    res += "}"; return res;
}

template <typename A, typename B> string ts(pair<A, B> p) {
    return "(" + ts(p.fi) + ", " + ts(p.se) + ")";
}

void dbg_out() { cerr << "]" << endl; }
template <typename H, typename... T> void dbg_out(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    dbg_out(t...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__) 
#else
    #define dbg(...) 0
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//const ll MOD = 1000000007; //998244353;
//const ll INF = LLONG_MAX;
//const db PI = 3.14159265358979323846;

ll n;
ll a[200005];

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b - c;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tc = 1;
    //cin >> tc;
    while (tc--)
        solve();
}