#include <bits/stdc++.h>

using namespace std;

#define ll long long





int main()
{
   int t=1;
 //  cin>>t;



   while(t--)
   {

      int a,b,x,y;

      cin>>a>>b>>x>>y;


      cout<<(b-x)<<endl;




   }




  return 0;

}

// written by c++(gcc)
// -*- cording: utf-8 -*-
#include <stdio.h>

// 最大値を返す関数
int max(int a, int b){
    int maxNum;
    
    if(a < b){
        maxNum = b;
    }else{
        maxNum = a;
    }

return maxNum;
}

int main(void){
    int a, b, c, d;
    int ans;

    scanf("%d %d", &a, &b);
    scanf("%d %d", &c, &d);
    
    ans = max(a-c, a-d);
    ans = max(ans, b-c);
    ans = max(ans, b-d);

    printf("%d\n", ans);
    
    return 0;
}