#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	double a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);

	adeg=30.0*h+m*0.50;
	
	bdeg=6.0*m;

	deg=fabs(adeg-bdeg);

	rad=deg*PI/180.0;
	
	answer=sqrt(a*a+b*b-2.0*a*b*cos(rad));

	printf("%.9f",answer);

			return 0;
	}


	





