#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define fst first #define snd second /* clang-format off */ template struct _vec { using type = vector::type>; }; template struct _vec { using type = T; }; template using vec = typename _vec::type; template vector make_v(size_t size, const T& init) { return vector(size, init); } template auto make_v(size_t size, Ts... rest) { return vector(size, make_v(rest...)); } template inline void chmin(T &a, const T& b) { if (b < a) a = b; } template inline void chmax(T &a, const T& b) { if (b > a) a = b; } /* clang-format on */ int main() { #ifdef DEBUG ifstream cin("in.txt"); #endif int A, B, C, D; while (cin >> A >> B >> C >> D) { int res = 0; while ((C + 1) * res <= D && res <= A && res * C <= B) ++res; cout << res - 1 << endl; } return 0; }