#include<iostream>
#include<string>
#include<vector>
#include<iterator>

using namespace std;

int main()

{
     int a,b,c,d,m,x,y;
     cin>> a >> b >> c >> d ;

     if(a>=b)
     {
         x=a;
     }
     else
     {
         x=b;
     }

     if(c<=d)
     {
         y=c;
     }
     else
     {
         y=d;
     }


     cout<<x-y<<"\n";

     return 0;
}

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

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