A, B, X, Y = map(int, input().split()) y = X / A * B if y > Y: y = 0 x = Y / B * A if x > X: x = 0 print(max(X + y, Y + x))