#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
	int A,B,H,M;
	double x,C,a;
	scanf("%d %d %d %d",&A,&B,&H,&M);
	a=5.0*H+(M/12.0)-M;
	if(a<0){
		a=-a;
	}
	if(a>30){
		a=60-a;
	}
	x=a*M_PI/30.0;
	C=sqrt(A*A+B*B-2.0*A*B*cos(x));
	printf("%lf\n",C);
	return 0;
}