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

typedef long long ll;
double maxcal(double x,double y)
{
  if(x>=y) return x-y;
  else return y-x;
}
 
int main(void)
{
  double a,b,h,m,p=3.1415926535898;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  double ra,rb,rab,c;
  ra=(60.0*h+m)/360*p;
  rb=m*p/30;
  rab=maxcal(ra,rb);
  c=a*a+b*b-2.0*a*b*cos(rab);
  c=sqrt(c);
  printf("%.10lf",c);

  
  return 0;
}