import java.util.*


fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val h = sc.nextInt()
  val m = sc.nextInt()

  println(abc168c(a, b, h, m))
}

private fun abc168c(a: Int, b: Int, h: Int, m: Int): Double {
  val ad = a.toDouble()
  val bd = b.toDouble()
  val hd = h.toDouble()
  val md = m.toDouble()


  val kakudo = 30.0 * hd - 6.0 * md + md / 2.0
  val rad = (2 * Math.PI * kakudo) / 360.0

  val ans = (ad * ad) + (bd * bd) - 2 * ad * bd * Math.cos(rad)

  return Math.sqrt(ans)
}

