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

int main(){
	double pai = 3.1415926535;
	int a,b,h,m;
	double sub,ans;
	double harg,marg,barg;
	scanf("%d %d %d %d",&a,&b,&h,&m);
	marg = (double)m*pai/30;
	harg = (double)h*pai/6 + (double)m*pai/360;
	if(harg == marg){
		sub = abs(b-a);
		printf("%.10lf",sub);
		return 0;
	}else if(harg > marg){
		barg = harg - marg;
	}else{
		barg = marg - harg;
	}
	sub = a*a + b*b - 2*a*b*cos(barg);
	ans = sqrt(sub);
	printf("%.10lf",ans);
	
	return 0;
}