#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
typedef long long LL;
#define debug(x) cout << "debug : " << x << endl;

//#define int long long

//#define LOCAL
signed main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
    int a, b, c, d; cin >> a >> b >> c >> d;
    int mx = -1e9;
    for(int i = a; i <= b; ++i) {
        for (int j = c; j <= d; ++j) {
            mx = max(i - j, mx);
        }
    }
    cout << mx << endl;

}

#include<iostream>
using namespace std;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y;
  if(a>b){
    x = a;
  }else x =  b;
  if(c>d){
    y =  d;
  }else y = c;
  cout<<x-y;
}
