#include<bits/stdc++.h>
using namespace std;
int main()
{int a,b,c,d; cin>>a>>b>>c>>d;
int ans=-1000000;
for(int i=a;i<=b;i++){
for(int j=c;j<=d;j++){
ans=max(ans,i-j);
}}
cout<<ans;
}
#include<iostream>
#include<iomanip>
#include<limits>
#include<vector>
#include<algorithm>
#include<bitset>
#include<string>
#include<queue>
#include<tuple>
#include<cmath>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<set>

using namespace std;
#define endl "\n"
typedef long long ll;
typedef string str;
const double pi=3.14159265358979323846;
const long long inf = 1LL << 60;
typedef pair<int, int> P;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template<class T> inline bool ch_min(T&,T);
template<class T> inline bool ch_max(T&,T);
void Yes(bool f){
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
void YES(bool f){
    if(f){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << b-c << endl;
}

template<class T> inline bool ch_min(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool ch_max(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}