local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

a, b, c, d = io.read():match("(%d+) (%d+) (%d+) (%d+)")
a = lltonumber(a)
b = lltonumber(b)
c = lltonumber(c)
d = lltonumber(d)

if b < a then
  a, b = b, a
  c, d = d, c
end

local lim = (b - a) / (d + 1LL)
local ret = a + lim
ret = tostring(ret):gsub("LL", "")
print(ret)