#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535897932384626433832795028841971693

 
 
int main()
 {
	double a,b,h,m;
	double adeg,bdeg,deg,rad,answer;
	
scanf("%lf%lf%lf%lf",&a,&b,&h,&m);


	adeg=30.0*h+m*0.50;
	bdeg=6.0*m;

	deg=abs(adeg-bdeg);

	
	if(deg>180.0){
		deg=deg-180.0;
	}

rad=(deg*PI)/180.0;




	
	answer=sqrt(a*a+b*b-2.0*a*b*cos(rad));




	printf("%.9f",answer);


	
			return 0;
	}


	





