#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>


#define rep(i,n) for(int i = 0; i < n; ++i)
#define all(x) x.begin(),x.end()
using namespace std;

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  while(a != b){
    if(a>b) a=a-b;
    else b = b-a;
  }
  return a;
}
//(8 4)

int main(void){
  int x[2], y[2];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  int  X,Y;
  X = abs(x[0]-x[1]);
  Y = abs(y[0]-y[1]);
  if( X < Y) swap(X,Y);

  if(gcd(X,Y) == 1){
    cout << X + Y - 1 << endl;
  }else{
    int g=gcd(X,Y);
    X/=g;
    Y/=g;
    cout << (X + Y -1) * g << endl;
  }
  

  return 0;
}

