fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(' ').map(String::toLong)
    val minute = h * 60 + m
    val hDeg = minute.toDouble() / 720.0 * 2 * Math.PI
    val mDeg = m / 60.0 * 2 * Math.PI

    val ax = a * Math.sin(hDeg)
    val ay = a * Math.cos(hDeg)
    val bx = b * Math.sin(mDeg)
    val by = b * Math.cos(mDeg)
    val xDiff = Math.abs(ax - bx)
    val yDiff = Math.abs(ay - by)
    val dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff)

    println(dist)
}
