#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long int gcd(long long int a, long long int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int x, y;
	x = abs(a - c);
	y = abs(b - d);
	cout << (x / gcd(x, y) + y / gcd(x, y) - 1)*gcd(x, y) << endl;
	return 0;
}