from math import ceil N, M, P, Q = map(int, input().split()) ans, mod = divmod(N, ((12+Q) * M)) if mod <= (P-1)*M: print(ans*12+ceil(mod/M)) elif mod >= (P+Q*2)*M: print(ans*12+ceil((mod-Q*M)/M)) else: mod -= (P-1)*M print(ans*12+P-1+ceil(mod/(M*2)))