import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {
  val Array(a, b, h, m) = readIntArr
  val a1: Double = 2D * Math.PI / 60.0 / 12.0 * (h * 60 + m)
  val a2: Double = 2D * Math.PI / 60.0 * m
  val x1 = Math.sin(a1) * a
  val y1 = Math.cos(a1) * a
  val x2 = Math.sin(a2) * b
  val y2 = Math.cos(a2) * b
  val dist = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
  println(dist)

  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }

  def readIntArr = StdIn.readLine().split(" ").map(_.toInt)
}




