import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (a, b, h, m) = readDs()
  val sa = (h + m / 60) * 30
  val sb = m * 6
  var d = abs(sa - sb)
  if (180.0 < d) d = 360.0 - d
  val x = sqrt(a * a + b * b - 2 * a * b * cos(d * PI / 180))
  println("%.10f".format(x))
}
