#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int i1, j1, i2, j2;
    cin >> i1 >> j1 >> i2 >> j2;

    i2 -= i1;
    j2 -= j1;
    i1 = 0;
    j1 = 0;
    i2 = abs(i2);
    j2 = abs(j2);

    if (i2 == 0 && j2 == 0) 
    {
        cout << 0 << endl;
        return 0;
    }
    
    if (i2 + j2 <= 3 || i2 == j2)
    {
        cout << 1 << endl;
        return 0;
    }

    if (i2 + j2 <= 6 || (i2 + j2) % 2 == 0 || abs(i2 - j2) <= 3) 
    {
        cout << 2 << endl;
        return 0;
    }

    cout << 3 << endl;
    return 0;

    

    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int a,b,x,y;
int main(){
	scanf("%d%d%d%d",&a,&b,&x,&y);
	if(a>b)printf("%d",min((a-b-1)*y+x,x*(((a-b)<<1)-1)));
	else printf("%d",min((b-a)*y+x,x*(((b-a)<<1)+1)));
	return 0;
}