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

int main(void){
	int a,b;
    double h, m, c, result;
  	scanf("%d",&a);
  	scanf("%d",&b);
  	scanf("%lf",&h);
  	scanf("%lf",&m);
  	
    c=abs((h*30+m*0.5)-m*6);
    result = a*a+b*b-2*a*b*cos(c/180.0*M_PI);
    result = sqrt(result);
  	printf("%.12f",result);
  		
  return 0;
}