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

#define pi 3.1415926535

int main(void){
  int a,b,h,m;
  scanf("%d%d%d%d",&a,&b,&h,&m);

  double angle = 11*pi*m/360 - pi*h/6;
  double l = sqrt(a*a+b*b-2*a*b*cos(angle));

  printf("%.9lf",l);
  return 0;
}