n,m,p,q = map(int,input().split()) month = list(range(1,13)) target = list(range(p,p+q)) index = 0 count=0 while n>0: #print(index) now_m = month[index] if now_m in target: n-=2*m else: n-=m index+=1 index%=12 count+=1 print(count)