scan = string.gmatch(io.read(),"%d+") n=scan() m=scan() p=scan() q=scan() r={1,1,1,1,1,1,1,1,1,1,1,1} n = n - 0 for i = p , p + q - 1 do r[i] = 2 end month = 0 while n > 0 do month = month + 1 n = n - m * r[((month - 1) % 12) + 1] end print(month)