N,M,P,Q = map(int,input().split()) now = 1 mod = 12 ans = 0 s =set() for _ in range(Q): s.add((P + _) % mod) while N: ans += 1 if now in s: N = max(0,N - 2 * M) else: N = max(0,N - M) now = (now + 1) % mod print(ans)