import kotlin.math.*

fun main() {
    val (a, b, h, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val md = m / 60.0 * 360.0
    val hd = (h * 60 + m) / 720.0 * 360
    val dig = if (abs(hd - md) > 180) {
        360 - abs(hd - md)
    } else {
        abs(hd - md)
    }
    val c = a * sin(Math.toRadians(dig))
    val aa = a * cos(Math.toRadians(dig))
    val d = sqrt(c.pow(2.0) + (b - aa).pow(2.0))
    println(d)
}