fun main(args : Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }

    val hd = ((360/12) * h) + ((360/12) * (m/60))
    val md = (360/60) * m

    //println("hd: $hd md: $md")

    val hr = Math.toRadians(hd)
    val mr = Math.toRadians(md)

    val hx = Math.sin(hr) * a
    val hy = Math.cos(hr) * a

    val mx = Math.sin(mr) * b
    val my = Math.cos(mr) * b

    //println("h(x, y) = ($hx, $hy)")
    //println("m(x, y) = ($mx, $my)")

    println(Math.sqrt(((mx - hx) * (mx - hx)) + ((my - hy) * (my - hy))))
}