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

fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (jisin: Long, hunsin: Long, h: Long, m: Long) = line.split(" ").map { it.toLong() }

    val hunsinKaku: Double = 2 * m * PI / 60L
    val hunsinX: Double = sin(hunsinKaku) * hunsin
    val hunsinY: Double = cos(hunsinKaku) * hunsin

    val jisinKaku: Double = 2 * PI * (h.toDouble() / 12L + m.toDouble() / (60L * 12L))
    val jisinX: Double = sin(jisinKaku) * jisin
    val jisinY: Double = cos(jisinKaku) * jisin

    val x = hunsinX - jisinX
    val y = hunsinY - jisinY

    val kyori = sqrt(x * x + y * y)

    println("${kyori}")
}