
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

ll gcd(ll a, ll b) {
	while (b != 0) {
		a = a % b;
		swap(a, b);
	}
	return a;
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll g = gcd(abs(a - c), abs(b - d));
	if (g != 1) {
		ll num1 = abs(a - c) / g;
		ll num2 = abs(b - d) / g;
		cout << (num1 + num2 - 1)*g << endl;
	}
	else
		cout << abs(a - c) / g + abs(b - d) - 1 << endl;
	return 0;
}