#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

int main(void)
{
	double a;
	double b;
	double h;
	double m;
	
	double L;
	double l;
	double rad;
	
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	
	rad=(((h+(m/60))/12)-(m/60))*2*PI;
	L=a*a+b*b-2*a*b*cos(rad);
	l = sqrt(L);
	printf("%.20f\n",l);
	
	return 0;
}