a, b = io.read("*n", "*n")
h, m = io.read("*n", "*n")

angle = h * 30 + m * 0.5

angle = angle * math.pi / 180

ax, ay = a * math.cos(angle), a * math.sin(angle)

z = m * 6
z = z * math.pi / 180

bx, by = b * math.cos(z), b * math.sin(z)

ret = (ax - bx) * (ax - bx) + (ay - by) * (ay - by)
ret = math.sqrt(ret)
print(string.format("%.10f", ret))
