#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a == c or b == d) cout << 0 << endl;
  else cout << abs(d-b) + abs(c-a) - gcd(abs(d-b),abs(a-c)) << endl;
  return 0;
}
