import kotlin.math.abs

fun main(args: Array<String>){

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

    val mm = Math.PI * 2 / 60.0 * m
    val hh = Math.PI * 2 * h / 12.0 + Math.PI * 2 / 12.0 * m / 60.0

    val c2 = a * a + b * b -2 * a * b * Math.cos(abs(mm - hh))
    print(Math.sqrt(abs(c2)))
}

