#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, x, y; cin >> a >> b >> x >> y;
	if(a == b)
	{
		cout << x << '\n';
		return 0;
	}
	cout << x + min(abs(a - b), abs(a - (b + 1))) * min(2 * x, y) << '\n';
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//0000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
//#define P pair<ll, ll>
//#define P pair<double, double>
#define PP pair<P,P>
#define T tuple<int,int,int>

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  if(a==c && b==d) cout << 0 << endl;
  else if(a+b==c+d || a-b==c-d || abs(a-c)+abs(b-d)<=3) cout << 1 << endl;
  else if((a+b)%2==(c+d)%2 || abs(a-c)+abs(b-d)<=6 || abs(abs(a-c)-abs(b-d))<=3) cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}
