object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, B, H, M = sc.nextDouble()
  val sideLength = (angle: Double) =>
    math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.toRadians(angle)))
  val hourHandAngle = ((360.0 / (12 * 60.0)) * (H * 60 + M)) % 360.0
  val minuteHandAngle = ((360.0 / 60.0) * M) % 360.0
  println {
    math.abs(hourHandAngle - minuteHandAngle) match {
      case 0.0 => math.abs(A - B)
      case 180.0 => A + B
      case angle if 180.0 < angle => sideLength(360.0 - angle)
      case angle => sideLength(angle)
    }
  }
}
