#include "bits/stdc++.h" using namespace std; int main() { int A,B,C,D,res,can; cin >> A >> B >> C >> D; res=0,can=0; can = B / C; if (A >= can){ res = can; } else{ res = A; B = C * A; } if (res+B <= D){ cout << res << endl; } else{ while(res+B >= D) { res -= 1; if(res<0){ res = 0; break; } B -= C; } cout << res << endl; } }