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

const int inf=0x3f3f3f3f;
const int maxn=1e5;
typedef long long ll;
int main(){
           ll a,b,c,d;
           cin>>a>>b>>c>>d;
          ll x=max(a,b);
          ll y=min(c,d);
          ll ans=x-y;
          cout<<ans<<endl;

           

}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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