#include<bits/stdc++.h>
    using namespace std;
//    #include <ext/pb_ds/assoc_container.hpp>
 //   #include <ext/pb_ds/tree_policy.hpp>
//    using namespace __gnu_pbds;
//    template <typename T>
//    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

    #define LOCAL 0

    #define length(a) (sizeof(a)/sizeof(a[0]))
    #define print(v,i,x) for(int j=i;j<=x;j++){cout<<v[j]<<" ";}cout<<endl;
    #define pb push_back
    #define mp make_pair
    #define lli long long int
    #define ulli unsigned long long int
    #define all(x) x.begin(),x.end()
    #define f first
    #define s second

    #define si(x) scanf("%d",&x);
    #define sli(x) scanf("%ld",&x);
    #define slli(x) scanf("%lld",&x);
    #define si2(x,y) {si(x);si(y);}
    #define si3(x,y,z) {si(x);si(y);si(z);}
    #define slli2(x,y) {slli(x);slli(y);}
    #define slli3(x,y,z) {slli(x);slli(y);slli(z);}

    #define pi(x) printf("%d",x);
    #define pi2(x,y) printf("%d %d",x,y);
    #define pi3(x,y,z) printf("%d %d %d",x,y,z);
    #define pli(x) printf("%ld",x);
    #define plli(x) printf("%lld",x);
    #define plli2(x,y) printf("%lld %lld",x,y);
    #define plli3(x,y,z) printf("%lld %lld %lld",x,y,z);
    #define pn printf("\n");
    #define ps printf(" ");
    #define pc(c) printf("%c",c);

    #define FOR(n) for(int i=0;i<n;i++)
    #define FORi(x,n) for(int i=x;i<=n;i++)
    #define FORj(x,n) for(int j=x;j<=n;j++)
    #define FORk(x,n) for(int k=x;k<=n;k++)
    #define FORl(x,n) for(int l=x;l<=n;l++)
    #define ROFi(x,n) for(int i=x;i>=n;i--)
    #define ROFj(x,n) for(int j=x;j>=n;j--)
    #define ROFk(x,n) for(int k=x;k>=n;k--)
    #define ROFl(x,n) for(int l=x;l>=n;l--)

    #define debug(x) cout << "  - " << #x << ": " << x << endl;
    #define debugs(x, y) cout << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
    #define debugss(x, y, z) cout << "  - " << #x << ": " << x << "         " << #y << ": " << y << "         " << #z << ": " << z <<  endl;
    #define fastIO 	std::ios::sync_with_stdio(false);cin.tie(NULL);

    typedef vector<int> vi;
    typedef vector<long> vli;
    typedef vector<long long> vlli;
    typedef vector<string> vstr;

    typedef pair<int,int> prii;
    typedef pair<int,lli> prilli;
    typedef pair<lli,int> prllii;
    typedef pair<lli,lli> prllilli;

    template <class T>T max3(T a,T b,T c){return max2(max2(a,b),c);}
    template <class T>T min3(T a,T b,T c){return min2(min2(a,b),c);}
    template <class T>T max4(T a,T b,T c,T d){return max2(max2(a,b),max2(c,d));}
    template <class T>T min4(T a,T b,T c,T d){return min2(min2(a,b),max2(c,d));}

    const lli mod = 1000000007ll;
    const lli MOD = 1000000009ll;
    const lli INF = LLONG_MAX/10;
    const int inf = INT_MAX/2;

    lli count_bit(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
    lli check_bit(lli _mask,lli _i){lli x=1;return (_mask&(x<<_i))==0?0:1;}
    lli set_bit(lli _mask,lli _i){lli x=1;_mask=_mask|(x<<_i);return _mask;}
    lli powermod(lli _a,lli _b,lli _m=mod){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
    lli power(lli _a,lli _b){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
    lli add(lli a,lli b,lli m=mod){lli x=a+b;while(x>=m)x-=m;return x;}
    lli sub(lli a,lli b,lli m=mod){lli x=a-b;while(x<0)x+=m;return x;}
    lli mul(lli a,lli b,lli m=mod){lli x=a*b;x%=m;return x;}
    lli gcd(lli a,lli b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
    lli lcm(lli a,lli b){return (a*b)/gcd(a,b);}

     vector<string> _split(const string& s, char c) {
        vector<string> v;
        stringstream ss(s);
        string x;
        while (getline(ss, x, c))
            v.emplace_back(x);
        return v;
    }

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

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

/*
    bool prime[100010];
    lli pf[100010];
    void sieve(){
        FOR(100010){prime[i]=true;pf[i]=-1;}
        prime[0]=prime[1]=false;
        for(lli i=2;i<100010;i++){
            if(prime[i]){
                pf[i]=i;
                for(lli j=i*i;j<100010;j+=i)
                {prime[j]=false;if(pf[j]==-1)pf[j]=i;}
            }
        }
    }
*/

     prii operator +(const prii& l , const prii& r){
         prii ret;
         ret.f=l.f+r.f;
         ret.s=l.s+r.s;
         return ret;
     }

    struct cmp{
        bool operator()(int const & l,int const & r) {
            return true;
        }
    }myobject;



    int main() {

        if(LOCAL){
            freopen("C:\\Users\\Smit Patel\\Downloads\\3.in","r",stdin);
            freopen("C:\\Users\\Smit Patel\\Downloads\\4.txt","w",stdout);
        }

        int T=1;
        //si(T);

        while(T--){
            int a,b,c,d;
            cin>>a>>b>>c>>d;

  
            a=max(a,c);
            b=min(b,d);

            int ans=max(0,b-a);

            cout<<ans;

        }

        return 0;
    }


Measured memory_bytes: 256