#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define endl '\n'

ll dp[105][2];

int main(){
    ios_base::sync_with_stdio(false);
    ll a, b, x, y;
    cin >> a >> b >> x >> y;

    if(a == b) cout << x, exit(0);
    else {
        if(a > b) swap(a, b), b--; 
        int k = abs(a-b);   
        cout << x + min(y, 2*x) * k << endl;
    }
    
    return 0;
}
#include <iostream>
#include <vector>
#include<math.h>
#include<algorithm>
#include <float.h>
#include <iomanip>
#include<string>
using namespace std;

int main()
{
	int N, x_0, y_0, x_N, y_N;
	cin >> N >> x_0 >> y_0 >> x_N >> y_N;

	double R_x, R_y;
	R_x = ((double)x_0 + (double)x_N) / 2;
	R_y = ((double)y_0 + (double)y_N) / 2;
	double x, y;
	x = x_0 - R_x;
	y = y_0 - R_y;

	double theta,A_sin,A_cos;
	const double PI = 3.14159265358979323846;
	theta = 2 * PI/N;
	A_cos = cos(theta);
	A_sin = sin(theta);
	double A_x, A_y;
	A_x = A_cos * x - y * A_sin;
	A_y = A_sin * x + A_cos * y;

	double Ans_x, Ans_y;
	Ans_x = R_x + A_x;
	Ans_y = R_y + A_y;
	cout << Ans_x <<" "<< Ans_y;

}
