N, M, P, Q = map(int, input().split()) now = 0 month = [M] * 12 month[P - 1:P + Q - 1] = [2 * M] * Q while N > 0: N -= month[now % 12] now += 1 print(now)