n, m ,p, q = [int(_) for _ in input().split()] l = [] for i in range(p, p+q): l.append(i) ans = [] for i in range(1, 13): if i in l: ans.append([i, m*2]) else: ans.append([i, m]) x = n for i in range(5): for j in ans: x -= j[1] if x <= 0: print(i*12+j[0]) break if x <= 0: break