N,M,P,Q=map(int,input().split()) Q=P+Q-1 x=Q-P+1 y=M*((x*2)+(12-x)) ANS=N//y*12 N%=y for i in range(1,13): if N<=0: break ANS+=1 if P<=i<=Q: N-=2*M else: N-=M print(ANS)