n,m,p,q = map(int,input().split()) x = (n+m-1)//m t = 12 + q ans = x//t*12 x %= t for i in range(1,13): x -= 2 if p <= i < p+q else 1 ans += 1 if x<=0: break print(ans)