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

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


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

	deg=adeg-bdeg;

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

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

rad=deg*(3.1415926535897932384626433832795028841971693/180.0);




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




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


	
			return 0;
	}


	






