#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint sx, sy, tx, ty;

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}
int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> sx >> sy >> tx >> ty;
	llint x = abs(tx-sx), y = abs(ty-sy);
	
	if(x == 0 || y == 0){
		cout << 0 << endl;
		return 0;
	}
	
	llint g = gcd(x, y);
	x /= g, y /= g;
	
	llint ans = (x-1)+(y-1)+1;
	ans *= g;
	cout << ans << endl;
	
	return 0;
}