fun main() {
    val l = readLine()!!.split(' ').map { it.toDouble() }
    val hr = (l[2]+l[3]/60)/12
    val min = l[3]/60
    val pi = 6.28318530718
    val x = l[0]*l[0] + l[1]*l[1] - 2*l[0]*l[1]*Math.cos((hr-min)*pi)
    println(Math.sqrt(x))
}
