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

int main(){
	double a,b,h,m;
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
	h = h*60 + m;
	double h_angle = (2.0*M_PI*h)/720.0;
	double m_angle = (2.0*M_PI*m)/60.0;
	double ang = fabs(h_angle-m_angle);
	double len = sqrt(a*a+b*b-2.0*a*b*cos(ang));
	printf("%.9f",len);
}
