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

int main(){
	double  a,b,h,m;
	double t;
	double l;
	
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	
	 t = abs(30*h + 0.5*m - 6*m);
     if(t > 180){
		 t = t - 180;
	 }
	 if(t == 0){
		 l = abs(a-b);
	 }
	 else{
	 l = sqrt( a*a + b*b - cos(t*3.141592653589793238/180)*2*a*b);
 }
	 
	printf("%.15lf",l);
}