#include<stdio.h>
#include<math.h>

double fun(double x)
{
	return (x*M_PI)/180.0;
}
double fun2(double x)
{
	if (x<0)
		return x*-1;
	else
		return x;
}
int main()
{
	int a,b,c,d;
	double angle,angle2,x;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	angle=fun2(30*c-5.5*d);
	angle2=fun(angle);
	x=sqrt(a*a+b*b-2*a*b*cos(angle2));
	printf("%.20lf",x);
	return 0;

}
