import kotlin.math.*

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

    val degH = h * 30 + m * 0.5
    val degM = m * 6;
    val diff = min(abs(degH - degM), abs(degM - degH + 360))

    println(sqrt((a * a) + (b * b) - (2 * a * b * cos(diff.toDouble() * PI / 180))))
}
