# No.740 幻の木 from math import ceil n, m, p, q = [int(s) for s in input().split()] months = 0 while n > 0: if p <= months % 12 + 1 <= p + q - 1: n -= m * 2 else: n -= m months += 1 print(months)