import java.util.Scanner

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

  val PerMinutes = 1.0 / (12.0 * 60.0)

  val hourRadian = (2 * Math.PI) * (h / 12.0 + m * PerMinutes)
  val minutesRadian = 2 * Math.PI * m / 60.0

  val radian = Math.abs(hourRadian - minutesRadian)
  val resSquare = (a * a) + (b * b) - 2 * a * b * Math.cos(radian)
  println(Math.sqrt(resSquare))
}
