import java.io.PrintWriter
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (a, b, h, m) = readIntegerList()
    val aRad = (PI / 6.0) * (h + m / 60.0) // ((2 * PI) / 12 * h) + (2 * PI) / 12 *  m / 60
    val bRad = PI * m / 30.0 // 2 * PI * m / 60
    val rad = aRad - bRad
    val ans = sqrt(a * a + b * b - 2 * a * b * cos(rad))
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
