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

fun main() {
    val (a, b, h, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val hRad = PI * (h + m / 60.0) / 6
    val mRad = PI * m / 30
    val hx = sin(hRad) * a
    val hy = cos(hRad) * a
    val mx = sin(mRad) * b
    val my = cos(mRad) * b
    println("%.15f".format(sqrt((hx - mx).let{it * it} + (hy - my).let{it * it})))
}