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

int main(void){
	int a,b,h,m;
	scanf("%d %d %d %d",&a,&b,&h,&m);
	long double kaku,ans;
	kaku=fabs((h*60+m)*0.5-m*6);
	if(kaku>180){
		kaku=360-kaku;
	}
	
	ans=a*a+b*b-2*a*b*(long double)cos(kaku*3.14159265358979323846/180);
	
	printf("%.10Lf",sqrtl(ans));
	
	return 0;
}