fun main() {
    var (a, b, h, m) = readLine()!!.split(" ").map(String::toInt)
    val rad = 2 * Math.PI * ((h / 12.0) + (m / 60.0) / 12.0 - (m / 60.0))
    println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(rad)))
}



