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

int main() {
	// your code goes here
	int a,b,c,d,m,n;
	cin>>a>>b>>c>>d;
	m=max(a,b);
	n=min(c,d);
	cout<<m-n<<"\n";
	    
	
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> v;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m,i,j,k,a,b,c,t,q,sum = 0,cnt = 0,maxn = 0,ans = 0;
	cin>>n>>a>>b>>c;
	a*=n;
	b*=n;
	if(a<=c&&c<=b)cout<<"No";
	else cout<<"Yes";
}