import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toLong() }
    val rad1 = m.toDouble() / 60.0 * 2
    val bx = b * sin(rad1 * PI)
    val by = b * cos(rad1 * PI)
    var rad2 = (60 *h.toDouble() + m.toDouble()) / (12 * 60.0) * 2
    val ax = a * sin(rad2 * PI)
    val ay = a * cos(rad2 * PI)
    val ans = sqrt((ax - bx)*(ax - bx) + (ay - by)*(ay - by))
    println(ans)
}