#include using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) #define all(x) x.begin(),x.end() int main() { i64 a,b,c,d; cin >> a >> b >> c>> d; i64 ans = 0; for(int i = 0;i <= d;i++) { i64 m = i; if(m <= b) { ans = max(ans , min(a, m / c)); } } cout << ans << endl; }