import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

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

    var hd = (h + (m / 60.0)) / 6.0
    var md = m / 30.0

    var d = abs(hd - md)
    println(sqrt(a * a + b * b - 2 * a * b * cos(d * PI) ))

}