#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

const ll linf = 2e18 + 100;
const int inf = 1e9 + 100;
const ll mod = 1e9 + 7;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main() {

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << b - c << endl;


	return 0;
}
             /****************#####       بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم       #####********************/


 
#include<bits/stdc++.h>
using namespace std;
 
#define         endl                "\n"
#define         EPS                 1e-6
#define         F                   first
#define         sf                  scanf
#define         pf                  printf
#define         S                   second
#define         MP                  make_pair
#define         pb                  push_back
#define         PI                  acos(-1.0)
#define         NO                  cout<<"NO\n"
#define         No                  cout<<"No\n"
#define         no                  cout<<"no\n"
#define         YES                 cout<<"YES\n"
#define         Yes                 cout<<"Yes\n"
#define         yes                 cout<<"yes\n"
#define         sz(x)               int(x.size())
#define         all(a)              a.begin(),a.end()
#define         srt(x)              sort(x.begin(),x.end())
#define         clock_start         clock_t tStart = clock()
#define         MEM(a, b)           memset(a, (b), sizeof(a))         
#define         dbg(x)              cout << (#x) << " = " << (x) << endl
#define         Fast                ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define         dbg2(x, y)          cout << #x << " = " << x << " " << #y << " = " << y << endl
#define         dbg3(x, y, z)       cout << #x << " = " << x << " " << #y << " = " << y << " " << #z << " = " << z << endl
#define         show_time           cout<<"\n\nTime Taken: "<<fixed<<setprecision(3)<<(double)(clock() - tStart) /  CLOCKS_PER_SEC<<"s"
 

                     /******------- Some bit operations ------*****/
                     
long long     SetBit    (long long n, long long X)    { return n | (1LL << X); }//X-1 tomo bit 0 hole 1 korbe, 1 hole unchange
long long     ClearBit  (long long n, long long X)    { return n & ~(1LL << X); }//X-1 tomo bit 1 hole 0 korbe, 0 hole unchange
long long     ToggleBit (long long n, long long X)    { return n ^ (1LL << X); }//X-1 tomo bit 1 hole 0 korbe r 0 hole 1
bool          CheckBit  (long long n, long long X)    { return (bool)(n & (1LL << X)); }//X-1 tomo bit 1 naki 0 bolbe
 

                    /*******-----------Graph Moves------------*****/ 

const   int     dx[] = {1, -1, 0, 0};
const   int     dy[] = {0, 0, 1, -1};

const   int     kx[] = {-2, -2, -1, -1, 1, 1, 2, 2};      // Knights Move
const   int     ky[] = {-1, 1, -2, 2, -2, 2, -1, 1};     // Knights Move

const   int     Kx[] = {0, 0, 1, -1, -1, 1, -1, 1};     // Kings Move
const   int     Ky[] = {-1, 1, 0, 0, 1, 1, -1, -1};    // Kings Move

                   /*--------------------------------------------*/



            ///////////////////////////////////////////////////////////////////////////
        ///////////////////////// DO NOT TOUCH BEFORE THIS LINE //////////////////////////
            //////////////////////////////////////////////////////////////////////////

 
typedef     long long   ll;
typedef     pair<int,int>pi;
typedef     pair<ll,ll>pll;
const       int MAX  = 1e5 + 5;
const       int MOD  = 1e9 + 7;
const       int INF  = 1e9;
const       ll LINF  = 1e18;

void Test_Case();
void File();




void solve()
{
    int a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    x=max(a,b);
    y=min(c,d);
    cout<<x-y<<endl;

}



int main()
{
    Fast;

    File();
    //Test_Case();
    solve();
    
    return 0;
}

void Test_Case()
{
    int tc;
    cin>>tc;
    for(int R=1;R<=tc;R++)
    {
        //cout << "Case " << R << ": ";
        solve();
    }
}
void File()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}



