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

int main()
{
  float a,b,h,m;
  scanf("%f%f%f%f",&a,&b,&h,&m);
  //a^2 = b^2+c^2-2bc*cosA
  float radh,radm,rad;
  radh = h*(360/12)+(360/720)*m;
  radm = 6*m;
  if (radh - radm == 180 || radh - radm == -180)
  {
    printf("%f",h + m);
  }
  else if (radh - radm < 0)
  {
    if (radm - radh > 180)
    {
      rad = radm - radh - 180;
    }
    else
      rad = radm - radh;
  }
  else
  {
    if (radh - radm > 180)
    {
      rad = radh - radm - 180;
    }
    else
      rad = radh - radm;
  }
  float c;
  c = sqrt(a*a+b*b-2*a*b*cos(rad));
  printf("%f",c);
}