#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
	int a,b,h,m;
	double ans,kon;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	h=h*30;
	dpuble g;
	
	g=h+m/2.0;
	m=m*6;
	kon=abs(g-m);
	kon=kon*3.14159265/180.0;
	
	
	ans=a*a+b*b-2*a*b*cos(kon);
	ans=sqrt(ans);
	printf("%lf\n",ans);
	return 0;
}
	
	