#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950L
int main()
{
	int a,b,h,m;
	long double rad,length;

	scanf("%d%d%d%d",&a,&b,&h,&m);

	rad=2.0*PI*((long double)h/12.0+(long double)m/60.0/12.0-(long double)m/60.0);
	length=sqrtl((long double)(a*a+b*b)-(long double)(2.0*a*b)*cosl(rad));
	printf("%Lf",length);
	return 0;
}