import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val a, b, h, m = sc.nextDouble()
    val hh = (h % 12) * 30 + m / 2
    debug(hh)
    val mm = m * 6
    debug(mm)
    val diff = {
      val ss = math.abs(mm - hh)
      math.min(ss, 360 - ss)
    }
    debug(diff)
    val ans = math.sqrt(
      a * a + b * b - 2 * a * b * math
        .cos(math.toRadians(math.round(diff * 1000) / 1000))
    )
    debug(a * a, b * b, -2 * a * b, math.cos(diff))
    println(ans)
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
    Console.err.flush()
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}
