N, M, P, Q = map(int, input().split()) month_two = Q Q = P + Q - 1 month_one = 12 - month_two yearlost = (M * month_one) + ((2 * M) * month_two) ans = (N // yearlost) * 12 remain = N % yearlost if remain == 0: print(ans) else: for i in range(1, 13): if Q >= i >= P: remain -= 2 * M ans += 1 else: remain -= M ans += 1 if remain <= 0: print(ans) break