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




int main()
{

	int A=0,B=0,H=0,M=0;
	float thetaA=0,thetaB=0,x=0;
	
	scanf("%d %d %d %d",&A,&B,&H,&M);
	
	thetaA=(60*H+M)*M_PI/360;
	thetaB=M*M_PI/30;
	
	x=sqrt(A*A+B*B-2*A*B*cos(thetaA-thetaB));
	
	printf("%f",x);
	
	
	return 0;
}
