#include using namespace std; #define rep(i,n) for(ll i=0;i #define SPQ(T) priority_queue,greater> #define UNIQUE(a) sort(all(a));a.erase(unique(all(a)),a.end()) #define decimal cout<; using vi=vector; using vvi=vector; using vvvi=vector; constexpr ll inf=1001001001001001; constexpr int INF=1001001001; constexpr int mod=1000000007; template bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template bool chmax(T&a,T b){if(a bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);} template void out(T a){cout< void outp(T a){cout<<'('< void outvp(T v){rep(i,v.size())cout<<'('< void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout< void outvv(T v){rep(i,v.size())outv(v[i]);} void YesNo(bool b){if(b)out("Yes");else out("No");} void yesno(bool b){if(b)out("yes");else out("no");} void YESNO(bool b){if(b)out("YES");else out("NO");} ll modpow(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;} vi calc(ll x){vi v;while(x>0){v.eb(x%10);x/=10;}reverse(all(v));return v;} int main(){ ll a,b,n,m; cin>>a>>b>>n>>m; if(a==b) out(a); else if(a>b){ ll p=(a-b)/(n+1); out(b+p); } else{ ll p=(b-1)/(m+1); out(a+p); } }