import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt

data class Pos(val x: Double, val y: Double)

fun main() {
    val builder = StringBuilder()

    val (a, b, h, m) = readInputLine().split(" ").map { it.toDouble() }

    val mDeg = PI * 2L * (m / 60.0)
    val mPos = Pos(b * cos(mDeg), b * sin(mDeg))

    val hDeg = PI * 2L * ((h * 60.0 + m) / 720.0)
    val hPos = Pos(a * cos(hDeg), a * sin(hDeg))

    builder.appendln(sqrt((hPos.x - mPos.x) * (hPos.x - mPos.x) + (hPos.y - mPos.y) * (hPos.y - mPos.y)))

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
