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

fun main(args: Array<String>) {
  val (A,B,H,M) = readLine()!!.split(" ").map { it.toInt() }
  val deg = ((6-0.5)*(H*60+M))%360
  val x = sqrt(A*A + B*B - 2*A*B*cos((deg*PI)/180))
  println(x)
}

