N, M, P, Q = map(int, input().split()) month = 0 while N > 0: month += 1 N -= M if P <= 1 + (month - 1) % 12 < P + Q: N -= M print(month)