#include using namespace std; int main() { int n, m, p, q; cin >> n >> m >> p >> q; vector v(13, false); for (int i = 0; i < q; ++i) { v[p+i] = true; } int count = 0; int month = 1; while (n > 0) { count++; n -= m; if (v[month]) n -= m; month++; if (month > 12) month -= 12; } cout << count << endl; return 0; }