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

int main() {
	int a, b, h, m;
	long double the,l;
	scanf("%d %d %d %d", &a, &b, &h, &m);
	the = fabsl(3.1415926535897932384*(30*h-5.5*m)/180);
	l = sqrtl(a*a+b*b-2*a*b*cosl(the));
	printf("%.20Lf",l);
}