#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

#define int long long
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define max Max
#define min Min
#define abs Abs

using namespace std;

inline int read()
{
	int res=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=res*10+c-'0';c=getchar();}
	return res*f;
}

template<typename T,typename TT> inline T Max(T a,TT b){return a>b?a:b;}
template<typename T,typename TT> inline T Min(T a,TT b){return a>b?b:a;}
template<typename T> inline T Abs(T x){return x<0?-x:x;}

int a,b,x,y;

signed main()
{
	a=read();b=read();x=read();y=read();
	int ans=0;
	if(a>b) ans=min((abs(a-b)-1)*y+x,(abs(a-b)*2-1)*x);
	else if(a<b) ans=min(abs(a-b)*y+x,(abs(a-b)*2+1)*x);
	else if(a==b) ans=x;
	printf("%lld\n",ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ll long long
int f(int n){
    return n%10 + n%100/10 + n/100;
}
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(f(a), f(b)) << endl;
}