N, M, P, Q = map(int, input().split()) month_shed = [] for month in range(1, 13): end_month = P + Q - 1 if P <= month <= end_month: month_shed.append(2 * M) else: month_shed.append(M) sum_cycle = sum(month_shed) current_leaves = N count = 0 current_month = 1 # 1-based month (1-12) if sum_cycle > 0 and current_leaves >= sum_cycle: cycles = current_leaves // sum_cycle current_leaves -= cycles * sum_cycle count += cycles * 12 while current_leaves > 0: a = month_shed[current_month - 1] if current_leaves <= a: count += 1 break current_leaves -= a count += 1 current_month = (current_month % 12) + 1 print(count)