#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define MOD 1000000007 int main() { int a, b, c, d; cin >> a >> b >> c >> d; int ans = 0; for (int k = 0; k <= a; ++k) { if (c * k <= b && k + (c * k) <= d) { ans = max(ans, k); } } cout << ans << endl; return 0; }