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

int main()
{
	int ret, a, b, h, m;
	double len;
	double x,y;
	double hour,min;
	double angleA, angleB, diff;
	
	ret = scanf("%d %d %d %d", &a, &b, &h, &m);

	hour = h+(double)m/60.0;
	min  = (double)m/60.0;

	angleA = hour/12.0*360.0/180.0*M_PI;
	angleB = min/1.0*360.0/180.0*M_PI;
	diff = (angleA < angleB )?angleB - angleA: angleA - angleB;
	x = (double)b*cos(diff);
	y = (double)b*sin(diff);
	len = sqrt( (x - a)*(x-a) + y*y);
	printf("%20.16lf\n",len);
	fflush(stdout);
	return EXIT_SUCCESS;
}