#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
const int maxn = 300005;
const int inf = 1000000007;

int gcd(int x, int y) {
    if(y==0)return x;
    return gcd(y,x%y);
}

int main() {
   // freopen("in.cpp","r",stdin);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x = abs(a-c);
    int y = abs(b-d);
    if(x==0||y==0)cout<<0<<endl;
    else {
        int tt = gcd(x,y);
        x/=tt,y/=tt;
        ll ret=tt*(ll)(x+y-1);
        cout<<ret<<endl;
    }
    return 0;
}
