N,M,P,Q = map(int,input().split()) ans = 0 c = 0 while N > 0 : ans += 1 c += 1 if c > 12 : c -= 12 if P <= c <= Q : N -= 2*M else : N -= M print(ans)