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

const double pi = acos(-1.0);

int main()
{
	double hourlong,minutelong,hour,minute;
	scanf("%lf %lf %lf %lf",&hourlong,&minutelong,&hour,&minute);
	double hourangle,minuteangle;
	hourangle = hour*30 + minute/2;
	minuteangle = minute * 60;
	double delta;
	delta = abs(hourangle - minuteangle);
	if(delta > 180)
	{
		delta = 360 - delta;
	}
	//printf("%.10lf",delta);
	double result;
	result = sqrt(hourlong*hourlong + minutelong* minutelong - 2 * hourlong * minutelong * cos(pi*2*(delta/360)));
	printf("%.10f",result);
	return 0;
}
