#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int a,b,h,m;
	double shi,fen,j;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	shi=0.5*(h*60+m);
	fen=6*m;
	j = fabs(shi-fen);
	if(j>180)j=360-j;
	printf("%.20f",sqrt(a*a+b*b-2*cos(j*M_PI/180)*a*b));
	return 0;
}