// Arup Guha
// 6/18/2026
// Solution to Kattis Problem: Kattis Speedrun
// https://open.kattis.com/problems/kattisspeedrun

using namespace std;
#include <bits/stdc++.h>
typedef long long ll;

int main() {

    ll solved, total, sTime, cTime;
    cin >> solved >> total >> sTime >> cTime;

    // Super safe upper bound.
    ll res = (total-solved)*sTime;

    // The limits on the input allow for a brute force search over every
    // possible value of the # of problems solved.
    for (ll i=0; i<total; i++) {

        // After we solve i more problems, s is our new solve total.
        ll s = solved + i;

        // Do a little math and you'll find this is the minimum # of problems
        // we need to create to get above 50%.
        ll nCreate = max(0ll, total - 2*s + 1);

        // Cost for solving i problems and creating nCreate problems.
        ll cost = i*sTime + nCreate*cTime;

        // Take the best.
        res = min(res, cost);
    }

    // Ta da!
    cout << res << endl;
    return 0;
}
