import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, h, m) = in.readLine().split("\\s+").map(_.toInt)

    val theta1 = 2.0 * Math.PI * (h + m / 60.0) / 12.0
    val theta2 = 2.0 * Math.PI * m / 60.0

    out.println(
      Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(theta1 - theta2))
    )

    out.flush()
  }
}
