fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toLong() }
//    var rad = 2 * Math.PI * Math.abs(h / 12.0 + m / (12.0 * 60.0) - m / 60.0)
    var rad = Math.PI * Math.abs(60 * h - 11 * m) / 360.0
    if (rad > Math.PI) {
        rad = 2 * Math.PI - rad
    }
    System.err.println(rad)
    val a_square = a * a + b * b - 2 * a * b * Math.cos(rad)
    println(Math.sqrt(a_square))
}