#include using namespace std; int main() { int A, B, C, D; cin >> A >> B >> C >> D; if(A == 0) { if(0 < C) cout << 0 << endl; else cout << D/B << endl; return 0; } if(B == 0) { if(0 < D) cout << 0 << endl; else cout << C/A << endl; return 0; } cout << min(C/A, D/B) << endl; return 0; }