#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, x, y;
	cin >> a >> b >> x >> y;
	if (a<=b){
		cout << min(x+(b-a)*y, (b-a)*2*x+x) << endl;
		return 0;
	}
	else{
		cout << min(x+(a-b-1)*y, (a-b-1)*2*x+x) << endl;
		return 0;
	}
}
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
typedef long long ll;
typedef long double ld;
typedef std::pair <int, int> pii;
const int mod = 998244353;
int n, K;
ll ans;
int read() {
	char c = getchar(); int ans = 0;
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return ans;
}
void Write(ll x) {
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
}
int max(int x, int y) {return x > y ? x : y;}
int min(int x, int y) {return x < y ? x : y;}
ll calc(int m) {
	return min(n, m - 1) - max(1, m - n) + 1;
}
int main() {
	n = read(), K = read();
	for (int i = 2; i <= n * 2; i++)
		if (i - K >= 1 && i - K <= n * 2) ans += calc(i) * calc(i - K);
	return Write(ans), 0;
}
