N,M,P,Q=map(int,input().split()) during=[] month=1 cnt=0 for i in range(Q): x=(P+i)%12 if x==0: x=12 during.append(x) while(N>0): if month in during: N-=2*M else: N-=M month+=1 if month==13: month=1 cnt+=1 print(cnt)