#include int main(){ int n,m,p,q,now; scanf("%d %d %d %d", &n, &m, &p, &q); now = 1; while(n>0){ now++; if(now%12-p < 0){ n -= m; } else if(p+q-1-now%12>=0){ n -= 2*m; } else{ n -= m; } } printf("%d",now-1); return 0; }