fun main(args: Array<String>) {
    val (a, b, h, m) = getInts()

    val x = m * 6.0
    val y = h * 30 + m / 2.0
    val theta = (Math.max(x, y) - Math.min(x, y)) * Math.PI / 180.0
    println(len(a, b, theta))
}

fun len(a: Int, b: Int, theta: Double): Double {
    val c = b - a * Math.cos(theta)
    val d = a * Math.sin(theta)
    return Math.sqrt(c * c + d * d)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }