#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	int a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%d%d%d%d",&a,&b,&h,&m);

	adeg=30*h+m*0.5;
	
	bdeg=6*m;

	deg=adeg-bdeg;

	if(deg<0)
	{
		deg=-deg;
	}

	if(deg>180)
	{
		deg=deg-180;
	}
	rad=deg*(PI/180);
	
	answer=sqrt(a*a+b*b-2*a*b*cos(rad));

	printf("%.10lf",answer);

			return 0;
	}


	





