fun main() {
    var (a, b, h, m) = readLine()!!.split(" ").map(String::toInt)

    val ta = (360 * (h / 12.0) + 30.0 * (m / 60.0)) % 360
    val ma = (360 * (m / 60.0)) % 360

    var angle = Math.abs(ta - ma)
    angle = if (angle > 180) {
        360 - angle
    } else {
        angle
    }

    println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))))
}



