import math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, h, m = sc.nextInt

  var d = (30 * h + (0.5 * m) - 6 * m).abs
  if (d > 180) {
    d = 360 - d
  }

  println(sqrt(a * a + b * b - 2 * a * b * cos(toRadians(d))))
}