#include <stdio.h>
#include <math.h>
 
int main(void)
{
  int a, b, h, m;
  int minutes;
  double kakudo_m, kakudo_h, kakudo, len;
  
  scanf("%d%d%d%d", &a,&b,&h,&m);
  minutes = h * 60 + m;
  kakudo_m = (minutes % 360) * (double)6;
  kakudo_h = (double)(minutes*360) / (12*60);
  kakudo = (double)(fabs(kakudo_h - kakudo_m));
  kakudo = (kakudo * M_PI) / 180;
  len = sqrt(a*a + b*b - 2*a*b*cos(kakudo));
  printf("%lf", len);
  return 0;
}
  