import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val Array(a,b,h,m) = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  def solve() = {
    val angle = 360 * { (h.toDouble + m.toDouble/60) / 12 - m.toDouble/60 }
    Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(angle.toRadians))
  }

  println(solve())

}

