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

#define M_PI 3.14159265358979323846

int main(void)
{
	double a=0, b=0;
	double h=0, m=0;
	double aa=0, bb=0;
	double x=0;
	//float cosx=0;
	//float sinh,cosh,sinm, cosm, sinx, cos;
	
	double ans = 0;
	
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&h);
	scanf("%lf",&m);
	
	aa = (((60*h)+m)/720)*2*M_PI;
	bb = (m/60)*2*M_PI;
	x = fabs(aa-bb);
	
	//printf("%f %f %f %f\n",a, b, h, m);
	
	/*
	//θ分割
	if(h < 3){
		sinh = sin(((3-h)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else if(h<6){
		sinh = sin(((h-3)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else if(h<9){
		sinh = sin(((9-h)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else{
		sinh = sin(((h-9)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	
	if(m <15){
		sinm = sin(((15-m)/15)*M_PI*0.5);
	}
	*/	
		
	
	//printf("aa = %f  bb = %f\n",aa,bb);
	
	//cosx = cos(aa)*cos(bb) + sin(aa)*sin(bb);
	//printf("cosx = %f\n",cos(x));
	
	ans = sqrt((a*a) + (b*b) - (2*a*b*cos(x)));
	
	printf("%15.14lf\n",ans);
	
	return 0;
}