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

int main(void)
{
	double a, b, h, m,ans;
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	h += m / 60;
	h = h * M_PI / 6;
	m = m * M_PI / 30;
	
	h=fabs(h - m);

	
	ans = sqrt(a*a+b*b-2*a*b*cos(h));

	printf("%.16f",ans);

	return 0;
}