import kotlin.math.*

fun main() {
    val input = readLine()!!.split(' ').map { it.toDouble() }
    println(a(input[0], input[1], theta(input[2], input[3])))
}

fun theta(h: Double, m: Double): Double {
    val md = m / 60
    val hd = h / 12
    val hTheta = 2 * PI * (hd + md / 12)
    val mTheta = 2 * PI * md
    return abs(hTheta - mTheta).let { if (it > PI) 2 * PI - it else it }
}

fun a(b: Double, c: Double, theta: Double): Double = sqrt(b.pow(2) + c.pow(2) - 2 * b * c * cos(theta))