#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> A >> B >> C >> D; ll ans = 0; FOR(a, 1, A+1){ ll need_meat = a * C; if(need_meat > B){ break; }else{ ll eat_sum = a + need_meat; if(eat_sum > D){ break; }else{ ans = a; } } } p(ans); return 0; }