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

#define pi 3.14159

int main()
{
	int a,b,h,m;
	scanf("%d %d %d %d",&a,&b,&h,&m);
	
	long double agl=2*pi*(long double)h/12.0+((long double)m/60.0)/12.0-(long double)m/60.0;
	
	long double r=(long double)(a*a+b*b)-(long double)(2*a*b)*cos(agl);
	
	printf("%.20Lf\n",sqrt(r));
	
	return 0;
}