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

int main(void){
	long long a,b;
    long double h, m, c, result;
  	scanf("%lld",&a);
  	scanf("%lld",&b);
  	scanf("%Lf",&h);
  	scanf("%Lf",&m);
  	
    c=h*30.0+m*0.5-m*6.0;
    if(c<0) c*=-1;

  	if(c>180.0) c=360.0-c;
    result = a*a+b*b-2*a*b*cosl(c*M_PI/180.0);
    result = sqrtl(result);
  	printf("%.12Lf",result);
  		
  return 0;
}