import kotlin.math.*

fun main() {
    val l = readLine()!!.split(" ")
    val A = l[0].toDouble()
    val B = l[1].toDouble()
    val H = l[2].toInt()
    val M = l[3].toInt()

    val tha = (H*30 + M*0.5) * (PI/180)
    val thb = (M*6) * (PI/180)

    val th = abs(tha - thb)

    val c = sqrt(A*A + B*B - 2*A*B*cos(th))

    println("%.20f".format(c))
}