#include <stdio.h>
#include <math.h>
 
int main(void) {

	double a, b, h, m, wh, wm, pi = 3.14159265359, oh, om, o;
	
	scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
	
	h = h * 60 * 60; //秒変換
	m = m * 60;
	
	wh = 2 * pi / 43200;
	oh = wh * h;
	
	wm = 2 * pi / 43200;
	om = wm * m;
	

	
	
	if(oh < om)
		o = om - oh;
	else if(oh > om)
		o = oh - om;
	else if(oh == om){
		printf("%lf", b - a);
		return 0;
	}
	else if((oh - om > 3.13 && oh - om < 3.15) || (om - oh > 3.13 && om - oh < 3.15)){
		printf("%lf", b + a);
		return 0;
	}
	 
	if(o > pi)
		o == 6.28318530718 - o;
	if(o == pi){
		printf("%lf", b + a);
		return 0;
	}
	
	printf("%lf", sqrt((a*a) + (b*b) - (2*a*b* cos(o))));
	
	
	
	
	return 0;
}