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

typedef struct{
	double y;
	double x;
} coordinate;



int main(void){
	const double PI= atan(1.0)*4;
	int a,b,h,m;
	double ans;
	coordinate lng,sht;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	lng.y=b*cos((double)m/30*PI);
	lng.x=b*sin((double)m/30*PI);
	//printf("lng: %f, %f\n",lng.y, lng.x);
	sht.y=a*cos((30*(double)h+0.5*(double)m)/180*PI);
	sht.x=a*sin((30*(double)h+0.5*(double)m)/180*PI);
	//printf("sht: %f, %f\n",sht.y, sht.x);
	ans=sqrt((lng.x-sht.x)*(lng.x-sht.x)+(lng.y-sht.y)*(lng.y-sht.y));
	printf("%.12f\n",ans);
	return 0;
}
