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

int main(){
	
	double h, m;
	double k;
	double ans;
	double a, b;
	
	scanf("%lf%lf%lf%lf", &a,  &b, &h, &m);
	
	k = h * 30 - 5.5;
	
	if(k < 0)
		k = k * (-1);
	
	if(k > 180)
		k = 360 - k;
	k = k * M_PI;
	ans = (a * a) + (b * b) - (2 * a * b * cos(k));
	
	printf("%.10lf", sqrt(ans));
	
	return 0;
}