N, M, P, Q = gets.split.map &:to_i leaf = N ans = 0 while leaf > 0 ans += 1 mon = (ans - 1) % 12 + 1 leaf -= mon.between?(P, P + Q - 1) ? 2 * M : M end p ans