/**
  *  Author: dhruv_gheewala
  *  Problem: A - Hands
  *  Date:   28.11.2020
  *  Time:   18:31:28
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define endl '\n'
#define int int64_t

typedef pair<int, int> pii;
typedef vector<int> vi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}

const int inf = 1e15;
const bool testcases = false;

void init_main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

void solve(int tc)
{
    int a, b, x, y;
    cin >> a >> b >> x >> y;

    if(a == b) {
        cout << x << endl;
        return;
    }

    if(a > b) {
        // a, 0 -> b + 1, 0
        // b + 1, 0 -> b, 1
        cout << (a - b - 1) * min(y, 2 * x) + x << endl;
    } else {
        // a, 0 -> b, 0
        // b, 0 -> b, 1
        cout << (b - a) * min(y, 2 * x) + x << endl;
    }
}

int32_t main(int32_t argc, char **argv)
{
    init_main();

    int TC = 1;
    if(testcases)
        cin >> TC;

    for(int tc = 1; tc <= TC; ++tc) {
        solve(tc);
        fundri;
    }
    return 0;
}
#include <bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
using ll = long long;
using P = pair<int , int>;

int main(int argc, char const *argv[])
{
	int a, b , c;
	cin >> a >> b >> c;
	a = 7-a;
	b = 7- b;
	c = 7-c;
	cout << a + b + c << endl;
	return 0;
}
