import kotlin.math.*

fun main() {
    val (a, b, h, m) = readLine()!!.split(" ").map(String::toDouble)
    val aK = 30.0 * h + 0.5 * m
    val bK = 6.0 * m

    val diff = Math.toRadians(abs(aK - bK))
    val result = sqrt((a * sin(diff)).pow(2.0) + (b - a * cos(diff)).pow(2.0))
    println(result)
}