import java.util.Scanner
import math._

object Main extends App{
	val sc=new Scanner(System.in)
	val a,b,h,m=sc.nextDouble
	val theta=abs((h*60+m)/(12*60)-m/60)*2*Pi
	val res=sqrt(a*a+b*b-2*a*b*cos(theta))
	println(res)
}