import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solveMulti(sc: Scanner, pw: java.io.PrintWriter) {
        for (t in 1..sc.next().toInt()) {
            solve(sc, pw)
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toDouble()
        val B = sc.next().toDouble()
        val H = sc.next().toDouble()
        val M = sc.next().toDouble()

//        val A = 100.0
//        val B = 100.0
//        val H = 0.0
//        val M = 45.0
        val degH = 2.0 * Math.PI * (H / 12 + M / 720)
        val degM = 2.0 * Math.PI * (M / 60)
//        lib.dprint("degH=$degH")
//        lib.dprint("degM=$degM")
        val hx = A * Math.cos(Math.PI / 2.0 - degH)
        val hy = A * Math.sin(Math.PI / 2.0 - degH)
        val mx = B * Math.cos(Math.PI / 2.0 - degM)
        val my = B * Math.sin(Math.PI / 2.0 - degM)
//        lib.dprint("hx=$hx, hy=$hy")
//        lib.dprint("mx=$mx, my=$my")

        val dx = Math.abs(hx - mx)
        val dy = Math.abs(hy - my)
//        lib.dprint("dx=$dx, dy=$dy")
        val l = Math.sqrt(dx * dx + dy * dy)
        pw.println(l)
    }
}
