import scala.math._
object Main extends App{
    val Array(a,b,preh,m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    
    val h = preh + m/60.0
    
    val pre_angle = (h - m/5.0).abs
    val angle = if(pre_angle <= 6) BigDecimal(pre_angle*30) else BigDecimal((12-pre_angle)*30)
    
    
    println(sqrt((a*a+b*b-2*a*b*cos(angle.toDouble.toRadians)).toDouble))
}
