#include <iostream>
using namespace std;
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a==c || b==d){
    cout << 0 << endl;
    return 0;
  }
  cout << abs(a-c)+abs(b-d)-gcd(abs(a-c),abs(b-d)) << endl;
}