#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i> A >> B >> C >> D; for (LL i = A; i >= 0; --i) { LL want = i * C; if (want + i > D) continue; if (want <= B) { out << i << std::endl; return 0; } } }