import scala.io.StdIn._

object Main extends App{
	val (a,b,h,m) = {
		val arr = readLine().split(" ", 4).map{_.toInt}
		(arr(0), arr(1), arr(2), arr(3))
	}
	
	val funshin = 6 * m
	val jishin = 30 * h + 0.5 * m
	
	val diff = math.abs(funshin - jishin)
	
	val angle = math.min(diff, 360 - diff)
	
	val result : Double = math.sqrt(a*a + b*b - 2*a*b*math.cos(2 * math.Pi * angle / 360))
	println(result)
}