object Main extends App{
  val input = io.StdIn.readLine.split(' ').map(_.toDouble)
  val A = input(0)
  val B = input(1)
  val H = input(2)
  val M = input(3)

  val radH = (H + M / 60d)  / 12.0d
  val radM = M / 30.0d

  val radD = radH - radM

  val posH = (0d, A)
  val posM = (- B*Math.sin(radD * Math.PI), B*Math.cos(radD * Math.PI))

  val distance = Math.sqrt( Math.pow(posH._1 - posM._1 , 2) + Math.pow(posH._2 - posM._2, 2) )

  printf("%.12f",distance)
}