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

int main(void){
  int a,b,h,m,theta1;
  double theta2,d,l;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  theta1=6*m;
  theta2=30*h+0.5*m;
  d=fabs(theta1-theta2);
  if(d<=180) l=sqrt(a*a+b*b-2*a*b*cos(2*M_PI*d/360));
  if(d>180) l=sqrt(a*a+b*b-2*a*b*cos(2*M_PI*(360-d)/360));
  printf("%.20f",l);

  return 0;
}