import kotlin.math.*

fun main() {
    val (a, b, h, m) = readLine()!!.split(" ").map{ it.toInt() }
    var deg = abs((h*30+m*0.5) - (m*6))
    if(deg >= 180) deg = 360 - deg
    println(sqrt(a*a + b*b - 2*a*b*cos(deg*PI/180)))
}