import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val angle = getAngle(h, m)
    print(sqrt(a.pow(2) + b.pow(2) - 2 * a * b * cos(Math.toRadians(angle))))
}

fun getAngle(h: Double, m: Double): Double {
    val angle = abs(h * 30 + 30 * m / 60 - m * 6)
    return if (angle > 180) 360 - angle else angle
}
