#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int A, B, C, D; cin >> A >> B >> C >> D; if (A == 0){ cout << D/B << endl; } else if (B == 0){ cout << C/A << endl; } else cout << min(C/A, D/B) << endl; return 0; }