#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int p,m,d,s,ans=0; cin >> p >> d >> m >> s; int n = 1+floor(((p-m)*1.0)/(d*1.0)); int tot = (n*(2*p-(n-1)*d))/2; //cout << tot << endl; if(tot <= s) { ans+=n; s-=tot; int np = m; ans += (s/np); } else { ans = 0; for(int i=1;i<=n;i++) { ans = i; int tot = (i*(2*p-(i-1)*d))/2; if(tot>s) { ans--; break; } } } cout << ans << endl; return 0; }