#include using namespace std; int main(){ int x, y, a, b; cin >> x >> y >> a >> b; if(x/a*b <= y){ cout << x + x/a*b << endl; return 0; } else { cout << y + y/b*a << endl; return 0; } return 1; }