#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    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<<endl;
}
int32_t main() 
{
    rapido;
    int t=1;
    //cin>>t;
    while(t--)
    solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

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