import java.awt.geom.*
import kotlin.math.*

fun <T> readList(del:String = " ",f:String.()->T) = readLine()!!.split(del).map {f(it)}

fun main() {
	val (a,b,h,m) = readList {toInt()}

	val sa = Point2D.Double(0.0,a.toDouble())
	val sb = Point2D.Double(0.0,b.toDouble())
	val da = Point2D.Double()
	val db = Point2D.Double()
	AffineTransform.getRotateInstance(PI*2/12*(h+m/60.0)).transform(sa,da)
	AffineTransform.getRotateInstance(PI*2/60*m).transform(sb,db)
	println(da.distance(db))
}
