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