object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datA, datB, datH, datM) = readLine.split(" ").map(_.toInt)

    val radA = (360.0 / 12) * datH + (360.0 / 12 / 60) * datM
    val radB = (360.0 / 60) * datM
    val radAB_ = math.abs(radA - radB)
    val radAB = if (radAB_ > 180) (360 - radAB_) else radAB_
    //println(radA + " " + radB + " " + radAB)
    val ans2 = (datA * datA) + (datB * datB) - (2 * datA * datB) * math.cos(radAB * (math.Pi / 180))

    val ans = math.sqrt(ans2)
    println(ans)
  }
}
