#include int main() { int N, M, P, Q; std::cin >> N >> M >> P >> Q; int now = 0; int blow = 0; while(N > 0) { now++; N-=M; if((now % 12) + 1 == P) { blow = Q; } if(blow > 0) { blow--; N-=M; } } std::cout << now << std::endl; return 0; }