#include <bits/stdc++.h>
using namespace std;

int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}

int main()
{
	int A, B, C, D, w, h;
	cin >> A >> B >> C >> D;
	w = abs(A - C);
	h = abs(B - D);
	cout << w + h - GCD(w, h) << endl;
	return 0;
}
