#include<bits/stdc++.h> using namespace std; int fun(double countA, double countB, double maxA, double maxB){ if(maxA == 0)return min(maxB, countB); if(maxB == 0)return min(maxA, countA); int a = countB/maxB; int b = ceil(countB/maxB); if(countA >= b+1){ double tmp = countB+(b+1)*maxA; return min(countA+countB, tmp); } else{ if(countA <= a-1)return (maxB+1)*countA+maxB; else if(countA==a)return (maxB+1)*countA; else if(countA == a+1) return countA+countB; } } int main(){ double countA, countB, maxA, maxB; cin >> countA >> countB >> maxA >> maxB; int a = fun(countA, countB, maxA, maxB); int b = fun(countB, countA, maxB, maxA); cout << max(a, b) << endl; }