#include <algorithm>
#include <iostream>
 
int main() {
  int a,b,c,d;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  std::cin >> d;

  std::cout << b-c << std::endl;
  return 0;
}
#include <bits/stdc++.h>
#define fi first
#define se second
#define is_in(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define rng(a) a.begin(),a.end()
#define rngr(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
const int inf = 1<<30;
const double pi = acos(-1);
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
#define vp vector<P>
#define vvp vector<vp>
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using CP = complex<double>;
double dot( const CP &z, const CP &w ){ return (z.real()*w.real() + z.imag()*w.imag()); }
double cross( const CP &z, const CP &w ){ return (z.real()*w.imag() - z.imag()*w.real()); }
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// const ll mod = 1000000007;
#define dame { puts("-1"); return;}
#define yn {puts("Yes");}else{puts("No");}
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max({a-c, a-d, b-c, b-d});
    cout << ans << endl;
    return 0;
}