import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val rad = PI * 2 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0)
    val rsq = (a * a + b * b) - (2 * a * b) * cos(rad)
    println(sqrt(rsq))
}