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


int main(){
	
	double i,j,N,A,B,H,M;
	
	double theta_a,theta_b;
	
	scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
	//printf("%lf %lf %lf %lf\n",A,B,H,M);
	if(H>=12)H -=12;
	theta_a = 30.*H;//(360/12 deg / hour)  60
	theta_b = 6.*M;//(360/60 deg/min)
	double sa = fabs(theta_a-theta_b);
	if(sa>180) sa = 360 -sa;
	//printf("sa:%lf deg\n",sa);
	double ans;
	
	ans = sqrt(A*A+B*B-2*A*B*cos(sa/180.*M_PI));

	printf("%lf\n",ans);
		
	return 0;
}
