# include <bits/stdc++.h>
# define ull unsigned long long
# define ll long long
# define double long double
# define pll pair<ll,ll>
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define max3(a,b,c) max(a,max(b,c))
# define min3(a,b,c) min(a,min(b,c))
# define all(x) x.begin(),x.end()
# define fill(a,b) memset(a,b,sizeof(a))
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(15) << x
# define endl "\n"

using namespace std;
const ll INF = 9223372036854775807;
const ll N = 300005;
const ll mod = 998244353;
const ll M = 30;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a,b,c,d; cin>>a>>b>>c>>d; ll ans = -19999999;
  for(ll x=a;x<=b;x++)
  {
      for(ll y=c;y<=d;y++) ans = max(ans,x-y);
  }
  cout<<ans<<endl;
}

#include <iostream>

using namespace std;

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