fun main(args: Array<String>) {
    val (A, B, H, M) = readLine()!!.split(" ").map(String::toInt)
    val h = H * 60 + M
    val xh = A * Math.cos((180 - h) * Math.PI / 360)
    val yh = A * Math.sin((180 - h) * Math.PI / 360)
    val xm = B * Math.cos((15 - M) * Math.PI / 30)
    val ym = B * Math.sin((15 - M) * Math.PI / 30)
    println(Math.sqrt((xh - xm) * (xh - xm) + (yh - ym) * (yh - ym)))
}