#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; B = C * A; } else{ res = A; B = C * A; } if (res+B<= D){ cout << res << endl; } else{ cout << "0" << endl; } }