fun main(args: Array<String>) {
    val (A, B, H, M) = readLine()!!.split(" ").map(String::toDouble)
    val h = H * 60 + M
    val a = V.deg(A, h * 360 / 720)
    val b = V.deg(B, M * 360 / 60)
    println(a.distanceTo(b))
}

data class V(val x: Double, val y: Double) {
    companion object {
        fun rad(A: Double, rad: Double) = V(A * Math.cos(rad), A * Math.sin(rad))
        fun deg(A: Double, deg: Double) = rad(A, d2r(deg))
        private fun d2r(d: Double) = d * Math.PI / 180
    }

    fun norm() = Math.sqrt(x * x + y * y)
    fun distanceTo(o: V) = Math.sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y))
}