#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff   first
#define ss   second
#define ll  long long
#define pb   push_back
#define mii  map<int,int>
#define pqb  priority_queue<int>
#define pqs  priority_queue<int,vi,greater<int> >
#define mod  1000000007
#define sp(x,y)  fixed<<setprecision(y)<<x
#define t(x)  int x; cin>>x; while(x--)
mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
#define setbits(x)  __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x)
#define fo(i,n) for(i=0;i<n;i++)
#define PI 3.1415926535897932384626
#define vinput(p,x) for(int i=0;i<x;i++) cin>>p[i].ff>>p[i].ss;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void SOE(int n)
{
        bool pr[n+1];
    memset(pr, true, sizeof(pr));

    for (int p=2; p*p<=n; p++)
    {
        if (pr[p] == true)
        {
            for (int i=p*2; i<=n; i += p)
                pr[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (pr[p])
          cout << p << " ";
}
bool isP(int n)
{  bool flag=1;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            flag = 0;
            break;
        }
    }
    if(n<=1)
    flag=0;
    else if(n==2)
    flag=1;
    return flag;
}

double convt(string s,string a)
{
   double x=(s[0]-'0')*10 + (s[1]-'0');
   x=(double)((int)x%12);
   if(a[0]=='P')
    x+=12;
   double y=(s[3]-'0')*10 + (s[4]-'0');
   x=x+(y/100);
   return x;
}

void aks()
{
 ll a, b,c ,d;
 cin>>a>>b>>c>>d;
 ll ans=-300;
 for(ll i=a;i<=b;i++)
    for(ll j=c;j<=d;j++)
      {
          if(ans<=i-j)
            ans=i-j;
      }
 cout<<ans<<"\n";

}


int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    // code here
      //  t(x)
           aks();
    return 0;
}

#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<tuple>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;

const int INF = 1 << 30;

int main(){
    int a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;

    cout << b - c<< endl;
}
