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

int main(){
	int A,B,H,M;
  
 	scanf("%d%d%d%d",&A,&B,&H,&M);
  	double rad = fabs( (30*H) - (6*M) );
  	if(rad > 180) rad = rad - 180;
  	double RAD = M_PI * rad / 180; 
  	printf("%lf", sqrt(A*A + B*B - 2*A*B*cos(RAD) ) );  	
  	
return 0;
}