#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b;
    cin>>c>>d;
    int maks = -999999;
    for(int i=a;i<=b;i++){
        for(int j=c;j<=d;j++){
            maks = max(maks,i-j);
        }
    }cout<<maks<<endl;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int result= b-c;
    cout<< result <<endl;
    return 0;


}

