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

int main(void){
	int a, b, h, m;
	double d = 0;
	double t = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &h);
	scanf("%d", &m);
	t = m/60.0 - (60.0*h+m)/720.0;
	if(t<0){
		t *= -1.0;
	}
	t *= 2*M_PI;
	d = a*a + b*b - 2.0*a*b*cos(t);
	d = sqrt(d);
	printf("%.10lf\n", d);
	return 0;
}
