#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

long long int getgcd(long long int m, long long int n)
{
	if(n == 0) return m;
	else return getgcd(n, m % n);
}

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