import kotlin.math.*

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }

    val rad: Double = PI * 2.0 * ( h/12.0 + ( (m/60.0) / 12.0 - m/60.0 ) )

    val rsq: Double = (a * a + b * b) - (2.0 * a * b) * cos(rad)

    println(sqrt(rsq))
}