#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b,c, d;
    cin>>a>>b>>c>>d;
    int ans = INT_MIN;
    for(int i=a;i<=b;i++)
    {
        for(int j=c;j<=d;j++)
            ans = max(ans, i-j);
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for(ll i = (ll)(m); i < (ll)(n); i++)
#define rep_inv(i, n, m) for(ll i = (ll)(n); i > (ll)(m); i--)

int main(){
  ll a, b, c, d;

  cin >> a >> b;
  cin >> c >> d;

  cout << (b - c) << "\n";
  
  return 0;
}
