import java.util.Scanner
import kotlin.math.*

fun main() {
	val scn = Scanner(System.`in`)
	val a = scn.nextInt()
	val b = scn.nextInt()
	val h = scn.nextInt()
	val m = scn.nextInt()
	val th = 2*PI*(h/12.0+m/(12.0*60))
	val tm = 2*PI*(m/60.0)
	println(sqrt(a*a+b*b-2*a*b*cos(th-tm)))
}