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

int main(void){
  int a=0,b=0,h=0,m=0;
  double rad=0.0;
  double ans=0.0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);

  rad=h*30.0+(double)m*30.0/60.0;
  rad=(double)m*360.0/60.0-rad;
  rad=rad/180.0*3.141592653589793;
  
  ans=sqrt((a*a+b*b)-(2*a*b*cos(rad)));
  
  printf("%.9lf",ans);
}