import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,M,P,Q = map(int,read().split()) drop_leaf = [M] * 12 drop_leaf[P-1:P-1+Q] = [M+M] * Q q,r = divmod(N,sum(drop_leaf)) m = -1 while r > 0: m += 1 r -= drop_leaf[m] answer = 12*q + m + 1 print(answer)