#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define req(i,n) for(int i = 1;i <= n; i++) #define rrep(i,n) for(ll i = n-1;i >= 0;i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a),rend(a) typedef long long ll; typedef long double ld; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e18; const int inf = 0x3fffffff; const int MAX = 2010000; const int MOD = 998244353; ll fac[MAX], finv[MAX], inv[MAX]; void COMint() { fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n, m,ans =0; cin >> a >> b >> n >> m; ans = min(a, b); if (a == b) cout << a << endl; else { if (a > b) { cout << b + (a - b) / (n + 1) << endl; } else { cout << a + (b - a) / (m + 1) << endl; } } }