#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+m/60)*30;
	B=6*m;
	c=A-B;
	if(c>180) {
		c=360-c;
	}
	else if(c<=-180) {
		c=360+c;
	}
	if(c==0) {
		if(a<=b)
		printf("%.10lf\n",b);
		else if(a>b)
		printf("%.10lf\n",a);
	}
	else if(c==180) {
		printf("%.10lf\n",a+b);
	}
	else if(c==90||c==-90) {
		x=a*a+b*b;
		x=pow(x,0.5);
		printf("%.10lf\n",x);
	}
	else {
		double d=c*M_PI/180;
		double f=cos(d);
		x=a*a+b*b-2*a*b*f;
		x=pow(x,0.5);
		printf("%.10lf\n",x);
	}
	return 0;
}