fun main(args: Array<String>) {
  val (A, B, H, M) = readInts()
  val m = 60 * H + M
  val a = m.toDouble() / (12 * 60)
  val b = M.toDouble() / 60

  val d = Math.abs(a - b)
  val dMin = Math.min(d, 1 - d)
  val rad = (2 * Math.PI) * dMin

  val result2 = A * A + B * B - 2 * A * B * Math.cos(rad)
  val result = Math.sqrt(result2)
  println(result)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
