#include "bits/stdc++.h"
using namespace std;
#define ll long long

int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-c<<endl;
    return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <unordered_map>
using namespace std;

#define MAXN 1000001
#define MAXN1 101
#define MAXN2 1001
#define mod 1000000007
#define CONSTANT 1e8
#define ll long long // pair<int,int>

ll res = 0;

int BS(vector<int> arr, int val){
    int l = 0, u = (int)arr.size() - 1, res = -1;
    while(l <= u){
        int mid = (l + u) / 2;
        // if()
    }
    return 0;
}

vector<pair<int,ll>> g(vector<pair<int,ll>> left, vector<pair<int,ll>> right){
    int l = (int)left.size();
    int r = (int)right.size();
    vector<ll> pref(r,0);
    vector<pair<int,ll>> arr(l + r);
    pref[0] = right[0].second;
    for(int i = 1; i < r; i++){
        pref[i] = right[i].second + pref[i - 1];
    }
    int j = 0, i = 0;
    while(i < l){
        // cout << "i: " << i << " " << j << endl;
        if(j < r && left[i].first > right[j].first){
            // curr += right[j].second;
            j++;
        }
        else{
            if(j - 1 >= 0){
                // cout << "Adding: " << pref[j - 1] << endl;
                res += pref[j - 1];
            }
            i++;
        }
    }
    i = 0;
    j = 0;
    int index = 0;
    while(i < (int)left.size() && j < (int)right.size()){
        if(left[i].first <= right[j].first)
            arr[index++] = left[i++];
        else arr[index++] = right[j++];
    }

    while(i < (int)left.size())
        arr[index++] = left[i++];
    while(j < (int)right.size())
        arr[index++] = right[j++];
    return arr;
}

vector<pair<int,ll>> f(vector<pair<int,ll>> arr, int n){
    if(n == 1) return arr;
    int mid = n / 2;
    vector<pair<int,ll>> left(mid), right(n - mid);
    for(int i = 0; i < mid; i++)
        left[i] = arr[i];
    for(int j = mid; j < n; j++)
        right[j - mid] = arr[j];
    left = f(left, mid);
    right = f(right, n - mid);
    arr = g(left, right);
    return arr;
}

void zz(vector<pair<int,ll>> &left, vector<pair<int,ll>> &right){
    int l = (int)left.size();
    int r = (int)right.size();
    vector<ll> pref(r,0);
    pref[0] = right[0].second;
    for(int i = 1; i < r; i++){
        pref[i] = right[i].second + pref[i - 1];
    }
    int j = 0, i = 0;
    while(i < l){
        // cout << "i: " << i << " " << j << endl;
        if(j < r && left[i].first > right[j].first){
            // curr += right[j].second;
            j++;
        }
        else{
            if(j - 1 >= 0){
                // cout << "Adding: " << pref[j - 1] << endl;
                res += pref[j - 1];
            }
            i++;
        }
    }
}

vector<pair<int,ll>> gg(vector<pair<int,ll>> &left, vector<pair<int,ll>> &right){
    int l = (int)left.size();
    int r = (int)right.size();
    vector<pair<int,ll>> arr(l + r);
    int i = 0;
    int j = 0;
    int index = 0;
    while(i < l && j < r){
        if(left[i].first <= right[j].first){
            left[i].second += j;
            arr[index++] = left[i++];
        }
        else{
            // left[i].second += j + 1;
            arr[index++] = right[j++];
        }
    }
    while(i < (int)left.size()){
        left[i].second += r;
        arr[index++] = left[i++];
    }
    while(j < (int)right.size())
        arr[index++] = right[j++];
    // zz(left, right);
    return arr;
}

vector<pair<int,ll>> ff(vector<pair<int,ll>> &arr, int n){
    if(n == 1) return arr;
    int mid = n / 2;
    vector<pair<int,ll>> left(mid), right(n - mid);
    for(int i = 0; i < mid; i++)
        left[i] = arr[i];
    for(int j = mid; j < n; j++)
        right[j - mid] = arr[j];
    left = ff(left, mid);
    right = ff(right, n - mid);
    arr = gg(left, right);
    return arr;
}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a - d, b - c) << endl;
}