#include using namespace std; int a, b, c, d; int main() { int x; cin >> a >> b >> c >> d; for (x = 0; x <= a; x++) { if (c * x > b || c * x + x > d) break; } x--; cout << x << endl; return 0; }