#include<stdio.h>
#include<math.h>
int main(void)
{
	double a,b,h,m,c;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	double A,B,x;
	A=h*30+0.5*m;
	B=6*m;
	c=A-B;
	x=a*a+b*b-2*a*b*cos(c*M_PI/180);
	x=pow(x,0.5);
	printf("%.10lf\n",x);
	return 0;
}