#include <iostream>
using namespace std;
int a, b, c, d;
int main() {
  cin >> a >> b >> c >> d;
  cout << b - c;
  return 0;
}
// coded by- mrNOBODY_

#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
#define ld long double
#define in(x) cin>>x;
#define print(x) cout<<x;
#define println(x) cout<<x<<"\n";
#define vec(x) vector<x>
#define endl "\n"
#define all(x) x.begin(),x.end()
#define inf 1e15
#define sqr(x) ((x) * (x))
#define fr(i,a,b) for(ll i=a;i<b;i++)
void OJ();
ll const M=1e9 +7;

using namespace std;

/*ll binpow(ll a,ll n){   
    ll res=1;
    while (n>0)
    {       
        if(n&1)
            res =res*a; 
        a=sqr(a);n>>=1;
    }
    return res;
}

ll binpow(ll a,ll n,ll m){
    ll res=1;
    while (n>0)
    {
        if(n&1)
            res=((res%m)*(a%m))%m;
        a=(a*a)%m;n>>=1;
    }
    return res;
}

bool comp(const pair<int,int> &a , const pair<int,int> &b){
     return a.first < b.second;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin.sync();

    ll a,b,c,d;
    in(a>>b>>c>>d)
    print(max(a,b)-min(c,d))
    return 0;
}

void OJ()
{
#ifndef ONLINE_JUDGE
    freopen("inputf.in", "r", stdin);
    freopen("outputf1.in", "w", stdout);
#endif
}