#include <bits/stdc++.h>
#define mod 1000000007
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>
#define vl vector<ll>
#define REP(s, e) for (auto i = s; i <= e; i++)
#define show(s) cout<<s<<" "
#define MAXI 2147483647
#define MAXL 9223372036854775807
#define FOR(a,b) for (ll i = a; i < b; i++)
using namespace std;
typedef signed long long int ll;

int main() {
    fast_io;
    int a,b,c; cin >> a >> b >> c;
    cout << 21 - (a+b+c);
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
using pi = pair<int,int>;
using vi = vector<int>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi> ;
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define sor(x) sort(all(x)) 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define lb lower_bound 
#define ub upper_bound
#define loop(i,a,b) for(int i = (a); i <=(b); ++i)
#define loopr(i,a,b) for(int i = (a); i >= (b); --i)
#define trav(a,x) for (auto& a: x)
#define rep(i,n) for(int i = 0 ; i<n ; ++i)
#define max3(a,b,c) max(a,max(b,c))
const int MOD = 1e9+7; // 998244353;
const int INF = 1e18;
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!

/*
	


*/

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

	int ans=x ;

	if(a==b)
	{
		cout<<ans<<"\n";
		return;
	}
	else if(a<b)
	{
		int op1=(b-a)*y;
		int op2=(b-a)*2*x;
		ans=ans+min(op2,op1);
		cout<<ans<<"\n";
		return ;
	}
	else
	{
		ans=0;
		int op1=(a-b-1)*y+x;
		int op2=2*(a-b-1)*x+x ;
		// deb(op2);
		ans=ans+min(op1,op2);
		cout<<ans<<"\n";
		return;
	}



}

int32_t main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr);	
int t=1;
// cin>>t;
while(t--){
	solve();
}
	return 0;
}

