import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

fun main() {
    val iLine = readLine()!!.split(" ").map(String::toInt)

    val a = iLine[0]
    val b = iLine[1]
    val h = iLine[2]
    val m = iLine[3]

    var angle = ( m * 2 * PI / 60.toDouble() ) - (h * 2 * PI / 12.toDouble() + (m * 2 * PI / (60.toDouble() * 12.toDouble())))
    if(angle > PI){
        angle = 2 * PI - angle
    }

    var result = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle)))

    //println(angle)
    println("%.10f".format(result))
}