#include using namespace std; #define int long long int MOD = (int)1e9 + 7; int INF = (int)2e18; // Comment out below and program paste // #include "UnionFind.hpp" // #include "power.hpp" int add(int a, int b) { return (a + b) % MOD; } signed main() { int A, B, C, D; cin >> A >> B >> C >> D; int ans = 0; while (true) { if (B >= C && D >= (C + 1)) { ++ans; --A; B -= A; D -= (C + 1); } else { break; } } cout << ans << endl; }