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

#define MPI  3.14159265358979323846

int main(void){
	int a,b,h,m,min;
	double deg_h,deg_m,theta,c;
	
	scanf("%d %d %d %d",&a,&b,&h,&m);
	min=h*60+m;
	deg_h=360*(min/(12*60.0));
	deg_m=360*(m/60.0);

	theta=deg_h-deg_m;
	theta*=theta<0?-1:1;
	theta=theta>180?360-theta:theta;
	c=a*a+b*b-2*a*b*cos(theta*MPI/180.0);
	c=sqrt(c);
	printf("%.20f\n",c);
	

    return 0;
}