fun main() = Thread(null, ::abc168c, "", 128 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc168c() {
    val (a, b, h, m) = readLine()!!.split(' ').map { it.toDouble() }

    val answer = Math.sqrt(
        (a * a) + (b * b) - (2 * a * b * Math.cos(
            Math.toRadians(
                Math.abs(((h / 12) * 360 + (m / 60 / 12) * 360) - (m / 60) * 360)
            )
        ))
    )

    println(answer)
}
