object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, H, M = in.nextDouble

  val ah = math.Pi * (0.5 - (60 * H + M) / 360)
  val hx = A * math.cos(ah)
  val hy = A * math.sin(ah)
  val am = math.Pi * (0.5 - M / 30)
  val mx = B * math.cos(am)
  val my = B * math.sin(am)
  def sq(d: Double): Double = d * d

  println(math.sqrt(sq(hx - mx) + sq(hy - my)))
}