import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (a, b, h, m) = readInts()

    val md = 2 * PI * m / 60.toDouble()
    val hd = 2 * PI * (h * 60 + m) / (12 * 60).toDouble()

    var d = abs(hd - md)
    // a2=b2+c2−2bccosA

    val bb = b * b
    val aa = a * a
    val ab = a * b * 2 * cos(d)
    println(sqrt(bb + aa - ab))
}
