#include using namespace std; int main() { int p, d, m, s; cin >> p >> d >> m >> s; int c = 0, sum = 0; p += d; while (1) { if (p-d <= m) { p = m; } else { p -= d; } sum += p; if (sum <= s) c++; else break; }//cout << endl; cout << sum << " " << p << endl; cout << c; return 0; }