#include using namespace std; int main() { int a,b,n,m; cin >> a >> b >> n >> m; if(a>b){ cout << b+a/n << endl; } else{ cout << a+b/m << endl; } }