import kotlin.math.cos
import kotlin.math.sqrt

fun main(){
    val (a,b, h, m) = readLine()!!.split(" ").map(String::toDouble)

    val angleH = h * 30 + m/60 * 30
    val angleM = m/60 * 360

    val angleHM = if(angleH > angleM){
        angleH - angleM
    }else{
        angleM - angleH
    }

    val distSquareRoot = a*a + b*b - 2*a*b*cos(Math.toRadians(angleHM))
    println(sqrt(distSquareRoot))
}