import kotlin.math.abs

fun main(){
    val (a,b,h,m) = readLine()!!.split(" ").map{it.toDouble()}


    val rad_a : Double = 2 * Math.PI * ((h/12.0) + (m/60.0/12.0))
    val rad_b : Double = 2 * Math.PI * (m/60.0)

    val rad_diff = abs(rad_a - rad_b)

    val disdis = (a * a + b * b - 2 * a * b * Math.cos(rad_diff))

    println(Math.sqrt(disdis))
}