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

 
 
int main()
 {
	int a,b,h,m,c,d,k,e;
	double answer,t,l;
	
scanf("%d%d%d%d",&a,&b,&h,&m);


	c=30*h;
	d=6*m;

	k=c-d;

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

	if(k>180){
		k=k-180;
	}

t=k*(3.14159265358979/180.0);




	
	answer=sqrt(a*a+b*b-2*a*b*cos(t));


	printf("%lf",answer);


	
			return 0;
	}


	





