object Main extends App {
  import scala.io.StdIn._
  val Array(a,b,h,m) = readLine().split(" ").map(_.toDouble)
  val rM = m/60 * 2 * Math.PI
  val rH = (h/12 + m/60 * 1/12) * 2 * Math.PI
  var ans = a * a + b * b - 2 * a * b * Math.cos(Math.abs(rH - rM))
  println(Math.sqrt(ans))
}